2012-12-12 05:25:42 +08:00
|
|
|
//===-- AMDGPUMCTargetDesc.cpp - AMDGPU Target Descriptions ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief This file provides AMDGPU specific target descriptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPUMCTargetDesc.h"
|
2015-09-26 05:41:28 +08:00
|
|
|
#include "AMDGPUELFStreamer.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "AMDGPUMCAsmInfo.h"
|
2015-06-27 05:15:07 +08:00
|
|
|
#include "AMDGPUTargetStreamer.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "InstPrinter/AMDGPUInstPrinter.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "SIDefines.h"
|
2015-03-11 06:03:14 +08:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2013-01-02 18:22:59 +08:00
|
|
|
#include "llvm/MC/MachineLocation.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
|
2014-04-22 10:03:14 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "AMDGPUGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "AMDGPUGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "AMDGPUGenRegisterInfo.inc"
|
|
|
|
|
|
|
|
static MCInstrInfo *createAMDGPUMCInstrInfo() {
|
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitAMDGPUMCInstrInfo(X);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCRegisterInfo *createAMDGPUMCRegisterInfo(const Triple &TT) {
|
2012-12-12 05:25:42 +08:00
|
|
|
MCRegisterInfo *X = new MCRegisterInfo();
|
|
|
|
InitAMDGPUMCRegisterInfo(X, 0);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCSubtargetInfo *
|
|
|
|
createAMDGPUMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
|
2015-07-11 06:43:42 +08:00
|
|
|
return createAMDGPUMCSubtargetInfoImpl(TT, CPU, FS);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCInstPrinter *createAMDGPUMCInstPrinter(const Triple &T,
|
2015-03-31 08:10:04 +08:00
|
|
|
unsigned SyntaxVariant,
|
2012-12-12 05:25:42 +08:00
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
2015-03-31 08:10:04 +08:00
|
|
|
const MCRegisterInfo &MRI) {
|
2012-12-12 05:25:42 +08:00
|
|
|
return new AMDGPUInstPrinter(MAI, MII, MRI);
|
|
|
|
}
|
|
|
|
|
2015-06-27 05:15:07 +08:00
|
|
|
static MCTargetStreamer *createAMDGPUAsmTargetStreamer(MCStreamer &S,
|
|
|
|
formatted_raw_ostream &OS,
|
|
|
|
MCInstPrinter *InstPrint,
|
|
|
|
bool isVerboseAsm) {
|
|
|
|
return new AMDGPUTargetAsmStreamer(S, OS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MCTargetStreamer * createAMDGPUObjectTargetStreamer(
|
|
|
|
MCStreamer &S,
|
|
|
|
const MCSubtargetInfo &STI) {
|
|
|
|
return new AMDGPUTargetELFStreamer(S);
|
|
|
|
}
|
|
|
|
|
2015-09-26 05:41:28 +08:00
|
|
|
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
|
|
|
|
MCAsmBackend &MAB, raw_pwrite_stream &OS,
|
|
|
|
MCCodeEmitter *Emitter, bool RelaxAll) {
|
|
|
|
if (T.getOS() == Triple::AMDHSA)
|
|
|
|
return createAMDGPUELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
|
|
|
|
|
|
|
|
return createELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
|
|
|
|
}
|
|
|
|
|
2015-06-13 11:28:10 +08:00
|
|
|
extern "C" void LLVMInitializeAMDGPUTargetMC() {
|
2016-10-10 07:00:34 +08:00
|
|
|
for (Target *T : {&getTheAMDGPUTarget(), &getTheGCNTarget()}) {
|
2015-03-19 07:15:49 +08:00
|
|
|
RegisterMCAsmInfo<AMDGPUMCAsmInfo> X(*T);
|
|
|
|
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(*T, createAMDGPUMCInstrInfo);
|
|
|
|
TargetRegistry::RegisterMCRegInfo(*T, createAMDGPUMCRegisterInfo);
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(*T, createAMDGPUMCSubtargetInfo);
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(*T, createAMDGPUMCInstPrinter);
|
|
|
|
TargetRegistry::RegisterMCAsmBackend(*T, createAMDGPUAsmBackend);
|
2015-09-26 05:41:28 +08:00
|
|
|
TargetRegistry::RegisterELFStreamer(*T, createMCStreamer);
|
2015-03-19 07:15:49 +08:00
|
|
|
}
|
|
|
|
|
2015-06-27 05:15:07 +08:00
|
|
|
// R600 specific registration
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(getTheAMDGPUTarget(),
|
2015-03-19 07:15:49 +08:00
|
|
|
createR600MCCodeEmitter);
|
2015-06-27 05:15:07 +08:00
|
|
|
|
|
|
|
// GCN specific registration
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(getTheGCNTarget(),
|
|
|
|
createSIMCCodeEmitter);
|
2015-06-27 05:15:07 +08:00
|
|
|
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterAsmTargetStreamer(getTheGCNTarget(),
|
2015-06-27 05:15:07 +08:00
|
|
|
createAMDGPUAsmTargetStreamer);
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterObjectTargetStreamer(
|
|
|
|
getTheGCNTarget(), createAMDGPUObjectTargetStreamer);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|