2012-05-05 04:18:50 +08:00
|
|
|
//===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides NVPTX specific target descriptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "NVPTXMCTargetDesc.h"
|
2013-08-06 22:13:27 +08:00
|
|
|
#include "InstPrinter/NVPTXInstPrinter.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "NVPTXMCAsmInfo.h"
|
2012-05-05 04:18:50 +08:00
|
|
|
#include "llvm/MC/MCCodeGenInfo.h"
|
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
|
2014-04-22 10:03:14 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2012-05-05 04:18:50 +08:00
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "NVPTXGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "NVPTXGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "NVPTXGenRegisterInfo.inc"
|
|
|
|
|
|
|
|
static MCInstrInfo *createNVPTXMCInstrInfo() {
|
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitNVPTXMCInstrInfo(X);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
static MCRegisterInfo *createNVPTXMCRegisterInfo(const TargetTuple &TT) {
|
2012-05-05 04:18:50 +08:00
|
|
|
MCRegisterInfo *X = new MCRegisterInfo();
|
|
|
|
// PTX does not have a return address register.
|
|
|
|
InitNVPTXMCRegisterInfo(X, 0);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2013-03-30 22:29:21 +08:00
|
|
|
static MCSubtargetInfo *
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
createNVPTXMCSubtargetInfo(const TargetTuple &TT, StringRef CPU, StringRef FS) {
|
2015-07-11 06:43:42 +08:00
|
|
|
return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS);
|
2012-05-05 04:18:50 +08:00
|
|
|
}
|
|
|
|
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
static MCCodeGenInfo *createNVPTXMCCodeGenInfo(const TargetTuple &TT,
|
2015-07-07 00:56:07 +08:00
|
|
|
Reloc::Model RM,
|
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL) {
|
2012-05-05 04:18:50 +08:00
|
|
|
MCCodeGenInfo *X = new MCCodeGenInfo();
|
2015-07-01 01:18:00 +08:00
|
|
|
|
|
|
|
// The default relocation model is used regardless of what the client has
|
|
|
|
// specified, as it is the only relocation model currently supported.
|
|
|
|
X->initMCCodeGenInfo(Reloc::Default, CM, OL);
|
2012-05-05 04:18:50 +08:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
static MCInstPrinter *createNVPTXMCInstPrinter(const TargetTuple &T,
|
2015-03-31 08:10:04 +08:00
|
|
|
unsigned SyntaxVariant,
|
2013-08-06 22:13:27 +08:00
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
2015-03-31 08:10:04 +08:00
|
|
|
const MCRegisterInfo &MRI) {
|
2013-08-06 22:13:27 +08:00
|
|
|
if (SyntaxVariant == 0)
|
2015-03-31 06:03:16 +08:00
|
|
|
return new NVPTXInstPrinter(MAI, MII, MRI);
|
2014-04-25 13:30:21 +08:00
|
|
|
return nullptr;
|
2013-08-06 22:13:27 +08:00
|
|
|
}
|
|
|
|
|
2012-05-05 04:18:50 +08:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeNVPTXTargetMC() {
|
2015-03-19 07:15:49 +08:00
|
|
|
for (Target *T : {&TheNVPTXTarget32, &TheNVPTXTarget64}) {
|
|
|
|
// Register the MC asm info.
|
|
|
|
RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T);
|
|
|
|
|
|
|
|
// Register the MC codegen info.
|
|
|
|
TargetRegistry::RegisterMCCodeGenInfo(*T, createNVPTXMCCodeGenInfo);
|
|
|
|
|
|
|
|
// Register the MC instruction info.
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo);
|
|
|
|
|
|
|
|
// Register the MC register info.
|
|
|
|
TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo);
|
|
|
|
|
|
|
|
// Register the MC subtarget info.
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo);
|
|
|
|
|
|
|
|
// Register the MCInstPrinter.
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);
|
|
|
|
}
|
2012-05-05 04:18:50 +08:00
|
|
|
}
|