2012-12-12 05:25:42 +08:00
|
|
|
//===-- AMDGPUMCTargetDesc.cpp - AMDGPU Target Descriptions ---------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
2018-05-01 23:54:18 +08:00
|
|
|
/// This file provides AMDGPU specific target descriptions.
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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"
|
2017-10-11 09:57:21 +08:00
|
|
|
#include "llvm/MC/MCAsmBackend.h"
|
2017-10-12 07:34:47 +08:00
|
|
|
#include "llvm/MC/MCCodeEmitter.h"
|
2015-03-11 06:03:14 +08:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2019-03-05 11:02:00 +08:00
|
|
|
#include "llvm/MC/MCInstrAnalysis.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2018-05-19 02:26:45 +08:00
|
|
|
#include "llvm/MC/MCObjectWriter.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#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"
|
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
#define NoSchedModel NoSchedModelR600
|
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "R600GenSubtargetInfo.inc"
|
|
|
|
#undef NoSchedModelR600
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "AMDGPUGenRegisterInfo.inc"
|
|
|
|
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "R600GenRegisterInfo.inc"
|
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
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();
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
if (TT.getArch() == Triple::r600)
|
|
|
|
InitR600MCRegisterInfo(X, 0);
|
|
|
|
else
|
|
|
|
InitAMDGPUMCRegisterInfo(X, 0);
|
2012-12-12 05:25:42 +08:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCSubtargetInfo *
|
|
|
|
createAMDGPUMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
if (TT.getArch() == Triple::r600)
|
|
|
|
return createR600MCSubtargetInfoImpl(TT, CPU, 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) {
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
if (T.getArch() == Triple::r600)
|
|
|
|
return new R600InstPrinter(MAI, MII, MRI);
|
|
|
|
else
|
|
|
|
return new AMDGPUInstPrinter(MAI, MII, MRI);
|
2012-12-12 05:25:42 +08:00
|
|
|
}
|
|
|
|
|
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) {
|
2018-02-17 06:33:59 +08:00
|
|
|
return new AMDGPUTargetELFStreamer(S, STI);
|
2015-06-27 05:15:07 +08:00
|
|
|
}
|
|
|
|
|
2015-09-26 05:41:28 +08:00
|
|
|
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
|
2017-10-11 09:57:21 +08:00
|
|
|
std::unique_ptr<MCAsmBackend> &&MAB,
|
2018-05-19 02:26:45 +08:00
|
|
|
std::unique_ptr<MCObjectWriter> &&OW,
|
2017-10-12 07:34:47 +08:00
|
|
|
std::unique_ptr<MCCodeEmitter> &&Emitter,
|
|
|
|
bool RelaxAll) {
|
2018-05-19 02:26:45 +08:00
|
|
|
return createAMDGPUELFStreamer(T, Context, std::move(MAB), std::move(OW),
|
2017-10-12 07:34:47 +08:00
|
|
|
std::move(Emitter), RelaxAll);
|
2015-09-26 05:41:28 +08:00
|
|
|
}
|
|
|
|
|
2019-03-05 11:02:00 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class AMDGPUMCInstrAnalysis : public MCInstrAnalysis {
|
|
|
|
public:
|
|
|
|
explicit AMDGPUMCInstrAnalysis(const MCInstrInfo *Info)
|
|
|
|
: MCInstrAnalysis(Info) {}
|
|
|
|
|
|
|
|
bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
|
|
|
|
uint64_t &Target) const override {
|
|
|
|
if (Inst.getNumOperands() == 0 || !Inst.getOperand(0).isImm() ||
|
|
|
|
Info->get(Inst.getOpcode()).OpInfo[0].OperandType !=
|
|
|
|
MCOI::OPERAND_PCREL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int64_t Imm = Inst.getOperand(0).getImm();
|
|
|
|
// Our branches take a simm16, but we need two extra bits to account for
|
|
|
|
// the factor of 4.
|
|
|
|
APInt SignedOffset(18, Imm * 4, true);
|
|
|
|
Target = (SignedOffset.sext(64) + Addr + Size).getZExtValue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
static MCInstrAnalysis *createAMDGPUMCInstrAnalysis(const MCInstrInfo *Info) {
|
|
|
|
return new AMDGPUMCInstrAnalysis(Info);
|
|
|
|
}
|
|
|
|
|
2015-06-13 11:28:10 +08:00
|
|
|
extern "C" void LLVMInitializeAMDGPUTargetMC() {
|
AMDGPU: Separate R600 and GCN TableGen files
Summary:
We now have two sets of generated TableGen files, one for R600 and one
for GCN, so each sub-target now has its own tables of instructions,
registers, ISel patterns, etc. This should help reduce compile time
since each sub-target now only has to consider information that
is specific to itself. This will also help prevent the R600
sub-target from slowing down new features for GCN, like disassembler
support, GlobalISel, etc.
Reviewers: arsenm, nhaehnle, jvesely
Reviewed By: arsenm
Subscribers: MatzeB, kzhuravl, wdng, mgorny, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46365
llvm-svn: 335942
2018-06-29 07:47:12 +08:00
|
|
|
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(getTheGCNTarget(), createAMDGPUMCInstrInfo);
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(getTheAMDGPUTarget(), createR600MCInstrInfo);
|
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::RegisterMCRegInfo(*T, createAMDGPUMCRegisterInfo);
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(*T, createAMDGPUMCSubtargetInfo);
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(*T, createAMDGPUMCInstPrinter);
|
2019-03-05 11:02:00 +08:00
|
|
|
TargetRegistry::RegisterMCInstrAnalysis(*T, createAMDGPUMCInstrAnalysis);
|
2015-03-19 07:15:49 +08:00
|
|
|
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);
|
2018-02-17 06:33:59 +08:00
|
|
|
TargetRegistry::RegisterObjectTargetStreamer(
|
|
|
|
getTheAMDGPUTarget(), createAMDGPUObjectTargetStreamer);
|
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
|
|
|
}
|