You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.167
Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
parent
e19d552987
commit
b084638f15
@ -1,3 +0,0 @@
|
||||
add_llvm_library(LLVMRISCVAsmParser
|
||||
RISCVAsmParser.cpp
|
||||
)
|
@ -1,23 +0,0 @@
|
||||
;===- ./lib/Target/RISCV/AsmParser/LLVMBuild.txt ---------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[component_0]
|
||||
type = Library
|
||||
name = RISCVAsmParser
|
||||
parent = RISCV
|
||||
required_libraries = MC MCParser RISCVDesc RISCVInfo Support
|
||||
add_to_library_groups = RISCV
|
File diff suppressed because it is too large
Load Diff
31
external/llvm/lib/Target/RISCV/CMakeLists.txt
vendored
31
external/llvm/lib/Target/RISCV/CMakeLists.txt
vendored
@ -1,31 +0,0 @@
|
||||
set(LLVM_TARGET_DEFINITIONS RISCV.td)
|
||||
|
||||
tablegen(LLVM RISCVGenRegisterInfo.inc -gen-register-info)
|
||||
tablegen(LLVM RISCVGenInstrInfo.inc -gen-instr-info)
|
||||
tablegen(LLVM RISCVGenMCCodeEmitter.inc -gen-emitter)
|
||||
tablegen(LLVM RISCVGenMCPseudoLowering.inc -gen-pseudo-lowering)
|
||||
tablegen(LLVM RISCVGenAsmMatcher.inc -gen-asm-matcher)
|
||||
tablegen(LLVM RISCVGenAsmWriter.inc -gen-asm-writer)
|
||||
tablegen(LLVM RISCVGenDAGISel.inc -gen-dag-isel)
|
||||
tablegen(LLVM RISCVGenSubtargetInfo.inc -gen-subtarget)
|
||||
tablegen(LLVM RISCVGenDisassemblerTables.inc -gen-disassembler)
|
||||
|
||||
add_public_tablegen_target(RISCVCommonTableGen)
|
||||
|
||||
add_llvm_target(RISCVCodeGen
|
||||
RISCVAsmPrinter.cpp
|
||||
RISCVFrameLowering.cpp
|
||||
RISCVInstrInfo.cpp
|
||||
RISCVISelDAGToDAG.cpp
|
||||
RISCVISelLowering.cpp
|
||||
RISCVMCInstLower.cpp
|
||||
RISCVRegisterInfo.cpp
|
||||
RISCVSubtarget.cpp
|
||||
RISCVTargetMachine.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(AsmParser)
|
||||
add_subdirectory(Disassembler)
|
||||
add_subdirectory(InstPrinter)
|
||||
add_subdirectory(MCTargetDesc)
|
||||
add_subdirectory(TargetInfo)
|
@ -1,3 +0,0 @@
|
||||
add_llvm_library(LLVMRISCVDisassembler
|
||||
RISCVDisassembler.cpp
|
||||
)
|
@ -1,24 +0,0 @@
|
||||
;===- ./lib/Target/RISCV/Disassembler/LLVMBuild.txt ------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[component_0]
|
||||
type = Library
|
||||
name = RISCVDisassembler
|
||||
parent = RISCV
|
||||
required_libraries = MCDisassembler RISCVInfo Support
|
||||
add_to_library_groups = RISCV
|
||||
|
@ -1,274 +0,0 @@
|
||||
//===-- RISCVDisassembler.cpp - Disassembler for RISCV --------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the RISCVDisassembler class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/RISCVMCTargetDesc.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
|
||||
#include "llvm/MC/MCFixedLenDisassembler.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "riscv-disassembler"
|
||||
|
||||
typedef MCDisassembler::DecodeStatus DecodeStatus;
|
||||
|
||||
namespace {
|
||||
class RISCVDisassembler : public MCDisassembler {
|
||||
|
||||
public:
|
||||
RISCVDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx)
|
||||
: MCDisassembler(STI, Ctx) {}
|
||||
|
||||
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
|
||||
ArrayRef<uint8_t> Bytes, uint64_t Address,
|
||||
raw_ostream &VStream,
|
||||
raw_ostream &CStream) const override;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
static MCDisassembler *createRISCVDisassembler(const Target &T,
|
||||
const MCSubtargetInfo &STI,
|
||||
MCContext &Ctx) {
|
||||
return new RISCVDisassembler(STI, Ctx);
|
||||
}
|
||||
|
||||
extern "C" void LLVMInitializeRISCVDisassembler() {
|
||||
// Register the disassembler for each target.
|
||||
TargetRegistry::RegisterMCDisassembler(getTheRISCV32Target(),
|
||||
createRISCVDisassembler);
|
||||
TargetRegistry::RegisterMCDisassembler(getTheRISCV64Target(),
|
||||
createRISCVDisassembler);
|
||||
}
|
||||
|
||||
static const unsigned GPRDecoderTable[] = {
|
||||
RISCV::X0, RISCV::X1, RISCV::X2, RISCV::X3,
|
||||
RISCV::X4, RISCV::X5, RISCV::X6, RISCV::X7,
|
||||
RISCV::X8, RISCV::X9, RISCV::X10, RISCV::X11,
|
||||
RISCV::X12, RISCV::X13, RISCV::X14, RISCV::X15,
|
||||
RISCV::X16, RISCV::X17, RISCV::X18, RISCV::X19,
|
||||
RISCV::X20, RISCV::X21, RISCV::X22, RISCV::X23,
|
||||
RISCV::X24, RISCV::X25, RISCV::X26, RISCV::X27,
|
||||
RISCV::X28, RISCV::X29, RISCV::X30, RISCV::X31
|
||||
};
|
||||
|
||||
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > sizeof(GPRDecoderTable))
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
// We must define our own mapping from RegNo to register identifier.
|
||||
// Accessing index RegNo in the register class will work in the case that
|
||||
// registers were added in ascending order, but not in general.
|
||||
unsigned Reg = GPRDecoderTable[RegNo];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
static const unsigned FPR32DecoderTable[] = {
|
||||
RISCV::F0_32, RISCV::F1_32, RISCV::F2_32, RISCV::F3_32,
|
||||
RISCV::F4_32, RISCV::F5_32, RISCV::F6_32, RISCV::F7_32,
|
||||
RISCV::F8_32, RISCV::F9_32, RISCV::F10_32, RISCV::F11_32,
|
||||
RISCV::F12_32, RISCV::F13_32, RISCV::F14_32, RISCV::F15_32,
|
||||
RISCV::F16_32, RISCV::F17_32, RISCV::F18_32, RISCV::F19_32,
|
||||
RISCV::F20_32, RISCV::F21_32, RISCV::F22_32, RISCV::F23_32,
|
||||
RISCV::F24_32, RISCV::F25_32, RISCV::F26_32, RISCV::F27_32,
|
||||
RISCV::F28_32, RISCV::F29_32, RISCV::F30_32, RISCV::F31_32
|
||||
};
|
||||
|
||||
static DecodeStatus DecodeFPR32RegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > sizeof(FPR32DecoderTable))
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
// We must define our own mapping from RegNo to register identifier.
|
||||
// Accessing index RegNo in the register class will work in the case that
|
||||
// registers were added in ascending order, but not in general.
|
||||
unsigned Reg = FPR32DecoderTable[RegNo];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeFPR32CRegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > 8) {
|
||||
return MCDisassembler::Fail;
|
||||
}
|
||||
unsigned Reg = FPR32DecoderTable[RegNo + 8];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
static const unsigned FPR64DecoderTable[] = {
|
||||
RISCV::F0_64, RISCV::F1_64, RISCV::F2_64, RISCV::F3_64,
|
||||
RISCV::F4_64, RISCV::F5_64, RISCV::F6_64, RISCV::F7_64,
|
||||
RISCV::F8_64, RISCV::F9_64, RISCV::F10_64, RISCV::F11_64,
|
||||
RISCV::F12_64, RISCV::F13_64, RISCV::F14_64, RISCV::F15_64,
|
||||
RISCV::F16_64, RISCV::F17_64, RISCV::F18_64, RISCV::F19_64,
|
||||
RISCV::F20_64, RISCV::F21_64, RISCV::F22_64, RISCV::F23_64,
|
||||
RISCV::F24_64, RISCV::F25_64, RISCV::F26_64, RISCV::F27_64,
|
||||
RISCV::F28_64, RISCV::F29_64, RISCV::F30_64, RISCV::F31_64
|
||||
};
|
||||
|
||||
static DecodeStatus DecodeFPR64RegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > sizeof(FPR64DecoderTable))
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
// We must define our own mapping from RegNo to register identifier.
|
||||
// Accessing index RegNo in the register class will work in the case that
|
||||
// registers were added in ascending order, but not in general.
|
||||
unsigned Reg = FPR64DecoderTable[RegNo];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeFPR64CRegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > 8) {
|
||||
return MCDisassembler::Fail;
|
||||
}
|
||||
unsigned Reg = FPR64DecoderTable[RegNo + 8];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo == 0) {
|
||||
return MCDisassembler::Fail;
|
||||
}
|
||||
|
||||
return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo == 2) {
|
||||
return MCDisassembler::Fail;
|
||||
}
|
||||
|
||||
return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);
|
||||
}
|
||||
|
||||
static DecodeStatus DecodeGPRCRegisterClass(MCInst &Inst, uint64_t RegNo,
|
||||
uint64_t Address,
|
||||
const void *Decoder) {
|
||||
if (RegNo > 8)
|
||||
return MCDisassembler::Fail;
|
||||
|
||||
unsigned Reg = GPRDecoderTable[RegNo + 8];
|
||||
Inst.addOperand(MCOperand::createReg(Reg));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
// Add implied SP operand for instructions *SP compressed instructions. The SP
|
||||
// operand isn't explicitly encoded in the instruction.
|
||||
static void addImplySP(MCInst &Inst, int64_t Address, const void *Decoder) {
|
||||
if (Inst.getOpcode() == RISCV::C_LWSP || Inst.getOpcode() == RISCV::C_SWSP ||
|
||||
Inst.getOpcode() == RISCV::C_LDSP || Inst.getOpcode() == RISCV::C_SDSP ||
|
||||
Inst.getOpcode() == RISCV::C_FLWSP ||
|
||||
Inst.getOpcode() == RISCV::C_FSWSP ||
|
||||
Inst.getOpcode() == RISCV::C_FLDSP ||
|
||||
Inst.getOpcode() == RISCV::C_FSDSP ||
|
||||
Inst.getOpcode() == RISCV::C_ADDI4SPN) {
|
||||
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
||||
}
|
||||
if (Inst.getOpcode() == RISCV::C_ADDI16SP) {
|
||||
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
||||
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
||||
}
|
||||
}
|
||||
|
||||
template <unsigned N>
|
||||
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint64_t Imm,
|
||||
int64_t Address, const void *Decoder) {
|
||||
assert(isUInt<N>(Imm) && "Invalid immediate");
|
||||
addImplySP(Inst, Address, Decoder);
|
||||
Inst.addOperand(MCOperand::createImm(Imm));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
template <unsigned N>
|
||||
static DecodeStatus decodeSImmOperand(MCInst &Inst, uint64_t Imm,
|
||||
int64_t Address, const void *Decoder) {
|
||||
assert(isUInt<N>(Imm) && "Invalid immediate");
|
||||
addImplySP(Inst, Address, Decoder);
|
||||
// Sign-extend the number in the bottom N bits of Imm
|
||||
Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm)));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
template <unsigned N>
|
||||
static DecodeStatus decodeSImmOperandAndLsl1(MCInst &Inst, uint64_t Imm,
|
||||
int64_t Address,
|
||||
const void *Decoder) {
|
||||
assert(isUInt<N>(Imm) && "Invalid immediate");
|
||||
// Sign-extend the number in the bottom N bits of Imm after accounting for
|
||||
// the fact that the N bit immediate is stored in N-1 bits (the LSB is
|
||||
// always zero)
|
||||
Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm << 1)));
|
||||
return MCDisassembler::Success;
|
||||
}
|
||||
|
||||
#include "RISCVGenDisassemblerTables.inc"
|
||||
|
||||
DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||
ArrayRef<uint8_t> Bytes,
|
||||
uint64_t Address,
|
||||
raw_ostream &OS,
|
||||
raw_ostream &CS) const {
|
||||
// TODO: This will need modification when supporting instruction set
|
||||
// extensions with instructions > 32-bits (up to 176 bits wide).
|
||||
uint32_t Insn;
|
||||
DecodeStatus Result;
|
||||
|
||||
// It's a 32 bit instruction if bit 0 and 1 are 1.
|
||||
if ((Bytes[0] & 0x3) == 0x3) {
|
||||
Insn = support::endian::read32le(Bytes.data());
|
||||
DEBUG(dbgs() << "Trying RISCV32 table :\n");
|
||||
Result = decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI);
|
||||
Size = 4;
|
||||
} else {
|
||||
Insn = support::endian::read16le(Bytes.data());
|
||||
|
||||
if (!STI.getFeatureBits()[RISCV::Feature64Bit]) {
|
||||
DEBUG(dbgs() << "Trying RISCV32Only_16 table (16-bit Instruction):\n");
|
||||
// Calling the auto-generated decoder function.
|
||||
Result = decodeInstruction(DecoderTableRISCV32Only_16, MI, Insn, Address,
|
||||
this, STI);
|
||||
if (Result != MCDisassembler::Fail) {
|
||||
Size = 2;
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(dbgs() << "Trying RISCV_C table (16-bit Instruction):\n");
|
||||
// Calling the auto-generated decoder function.
|
||||
Result = decodeInstruction(DecoderTable16, MI, Insn, Address, this, STI);
|
||||
Size = 2;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
add_llvm_library(LLVMRISCVAsmPrinter
|
||||
RISCVInstPrinter.cpp
|
||||
)
|
@ -1,23 +0,0 @@
|
||||
;===- ./lib/Target/RISCV/InstPrinter/LLVMBuild.txt -------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[component_0]
|
||||
type = Library
|
||||
name = RISCVAsmPrinter
|
||||
parent = RISCV
|
||||
required_libraries = MC Support
|
||||
add_to_library_groups = RISCV
|
@ -1,86 +0,0 @@
|
||||
//===-- RISCVInstPrinter.cpp - Convert RISCV MCInst to asm syntax ---------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class prints an RISCV MCInst to a .s file.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "RISCVInstPrinter.h"
|
||||
#include "MCTargetDesc/RISCVBaseInfo.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
|
||||
// Include the auto-generated portion of the assembly writer.
|
||||
#define PRINT_ALIAS_INSTR
|
||||
#include "RISCVGenAsmWriter.inc"
|
||||
|
||||
static cl::opt<bool>
|
||||
NoAliases("riscv-no-aliases",
|
||||
cl::desc("Disable the emission of assembler pseudo instructions"),
|
||||
cl::init(false),
|
||||
cl::Hidden);
|
||||
|
||||
void RISCVInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
||||
StringRef Annot, const MCSubtargetInfo &STI) {
|
||||
if (NoAliases || !printAliasInstr(MI, O))
|
||||
printInstruction(MI, O);
|
||||
printAnnotation(O, Annot);
|
||||
}
|
||||
|
||||
void RISCVInstPrinter::printRegName(raw_ostream &O, unsigned RegNo) const {
|
||||
O << getRegisterName(RegNo);
|
||||
}
|
||||
|
||||
void RISCVInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O, const char *Modifier) {
|
||||
assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
|
||||
const MCOperand &MO = MI->getOperand(OpNo);
|
||||
|
||||
if (MO.isReg()) {
|
||||
printRegName(O, MO.getReg());
|
||||
return;
|
||||
}
|
||||
|
||||
if (MO.isImm()) {
|
||||
O << MO.getImm();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(MO.isExpr() && "Unknown operand kind in printOperand");
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
void RISCVInstPrinter::printFenceArg(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
unsigned FenceArg = MI->getOperand(OpNo).getImm();
|
||||
if ((FenceArg & RISCVFenceField::I) != 0)
|
||||
O << 'i';
|
||||
if ((FenceArg & RISCVFenceField::O) != 0)
|
||||
O << 'o';
|
||||
if ((FenceArg & RISCVFenceField::R) != 0)
|
||||
O << 'r';
|
||||
if ((FenceArg & RISCVFenceField::W) != 0)
|
||||
O << 'w';
|
||||
}
|
||||
|
||||
void RISCVInstPrinter::printFRMArg(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
auto FRMArg =
|
||||
static_cast<RISCVFPRndMode::RoundingMode>(MI->getOperand(OpNo).getImm());
|
||||
O << RISCVFPRndMode::roundingModeToString(FRMArg);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
//===-- RISCVInstPrinter.h - Convert RISCV MCInst to asm syntax ---*- C++ -*--//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class prints a RISCV MCInst to a .s file.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_RISCV_INSTPRINTER_RISCVINSTPRINTER_H
|
||||
#define LLVM_LIB_TARGET_RISCV_INSTPRINTER_RISCVINSTPRINTER_H
|
||||
|
||||
#include "MCTargetDesc/RISCVMCTargetDesc.h"
|
||||
#include "llvm/MC/MCInstPrinter.h"
|
||||
|
||||
namespace llvm {
|
||||
class MCOperand;
|
||||
|
||||
class RISCVInstPrinter : public MCInstPrinter {
|
||||
public:
|
||||
RISCVInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
|
||||
const MCRegisterInfo &MRI)
|
||||
: MCInstPrinter(MAI, MII, MRI) {}
|
||||
|
||||
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
|
||||
const MCSubtargetInfo &STI) override;
|
||||
void printRegName(raw_ostream &O, unsigned RegNo) const override;
|
||||
|
||||
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
|
||||
const char *Modifier = nullptr);
|
||||
void printFenceArg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printFRMArg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
|
||||
// Autogenerated by tblgen.
|
||||
void printInstruction(const MCInst *MI, raw_ostream &O);
|
||||
bool printAliasInstr(const MCInst *MI, raw_ostream &O);
|
||||
void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
|
||||
unsigned PrintMethodIdx, raw_ostream &O);
|
||||
static const char *getRegisterName(unsigned RegNo,
|
||||
unsigned AltIdx = RISCV::ABIRegAltName);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
35
external/llvm/lib/Target/RISCV/LLVMBuild.txt
vendored
35
external/llvm/lib/Target/RISCV/LLVMBuild.txt
vendored
@ -1,35 +0,0 @@
|
||||
;===- ./lib/Target/RISCV/LLVMBuild.txt -------------------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[common]
|
||||
subdirectories = AsmParser Disassembler InstPrinter TargetInfo MCTargetDesc
|
||||
|
||||
[component_0]
|
||||
type = TargetGroup
|
||||
name = RISCV
|
||||
parent = Target
|
||||
has_asmparser = 1
|
||||
has_asmprinter = 1
|
||||
has_disassembler = 1
|
||||
|
||||
[component_1]
|
||||
type = Library
|
||||
name = RISCVCodeGen
|
||||
parent = RISCV
|
||||
required_libraries = AsmPrinter Core CodeGen MC RISCVAsmPrinter RISCVDesc
|
||||
RISCVInfo SelectionDAG Support Target
|
||||
add_to_library_groups = RISCV
|
@ -1,8 +0,0 @@
|
||||
add_llvm_library(LLVMRISCVDesc
|
||||
RISCVAsmBackend.cpp
|
||||
RISCVELFObjectWriter.cpp
|
||||
RISCVMCAsmInfo.cpp
|
||||
RISCVMCCodeEmitter.cpp
|
||||
RISCVMCExpr.cpp
|
||||
RISCVMCTargetDesc.cpp
|
||||
)
|
@ -1,23 +0,0 @@
|
||||
;===- ./lib/Target/RISCV/MCTargetDesc/LLVMBuild.txt ------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[component_0]
|
||||
type = Library
|
||||
name = RISCVDesc
|
||||
parent = RISCV
|
||||
required_libraries = MC RISCVAsmPrinter RISCVInfo Support
|
||||
add_to_library_groups = RISCV
|
@ -1,239 +0,0 @@
|
||||
//===-- RISCVAsmBackend.cpp - RISCV Assembler Backend ---------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/RISCVFixupKinds.h"
|
||||
#include "MCTargetDesc/RISCVMCTargetDesc.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDirectives.h"
|
||||
#include "llvm/MC/MCELFObjectWriter.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCFixupKindInfo.h"
|
||||
#include "llvm/MC/MCObjectWriter.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class RISCVAsmBackend : public MCAsmBackend {
|
||||
uint8_t OSABI;
|
||||
bool Is64Bit;
|
||||
|
||||
public:
|
||||
RISCVAsmBackend(uint8_t OSABI, bool Is64Bit)
|
||||
: MCAsmBackend(), OSABI(OSABI), Is64Bit(Is64Bit) {}
|
||||
~RISCVAsmBackend() override {}
|
||||
|
||||
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
|
||||
const MCValue &Target, MutableArrayRef<char> Data,
|
||||
uint64_t Value, bool IsResolved) const override;
|
||||
|
||||
std::unique_ptr<MCObjectWriter>
|
||||
createObjectWriter(raw_pwrite_stream &OS) const override;
|
||||
|
||||
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
|
||||
const MCRelaxableFragment *DF,
|
||||
const MCAsmLayout &Layout) const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned getNumFixupKinds() const override {
|
||||
return RISCV::NumTargetFixupKinds;
|
||||
}
|
||||
|
||||
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override {
|
||||
const static MCFixupKindInfo Infos[RISCV::NumTargetFixupKinds] = {
|
||||
// This table *must* be in the order that the fixup_* kinds are defined in
|
||||
// RISCVFixupKinds.h.
|
||||
//
|
||||
// name offset bits flags
|
||||
{ "fixup_riscv_hi20", 12, 20, 0 },
|
||||
{ "fixup_riscv_lo12_i", 20, 12, 0 },
|
||||
{ "fixup_riscv_lo12_s", 0, 32, 0 },
|
||||
{ "fixup_riscv_pcrel_hi20", 12, 20, MCFixupKindInfo::FKF_IsPCRel },
|
||||
{ "fixup_riscv_jal", 12, 20, MCFixupKindInfo::FKF_IsPCRel },
|
||||
{ "fixup_riscv_branch", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
|
||||
{ "fixup_riscv_rvc_jump", 2, 11, MCFixupKindInfo::FKF_IsPCRel },
|
||||
{ "fixup_riscv_rvc_branch", 0, 16, MCFixupKindInfo::FKF_IsPCRel }
|
||||
};
|
||||
|
||||
if (Kind < FirstTargetFixupKind)
|
||||
return MCAsmBackend::getFixupKindInfo(Kind);
|
||||
|
||||
assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
|
||||
"Invalid kind!");
|
||||
return Infos[Kind - FirstTargetFixupKind];
|
||||
}
|
||||
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const override { return false; }
|
||||
|
||||
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
|
||||
MCInst &Res) const override {
|
||||
|
||||
report_fatal_error("RISCVAsmBackend::relaxInstruction() unimplemented");
|
||||
}
|
||||
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
|
||||
};
|
||||
|
||||
bool RISCVAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
// Once support for the compressed instruction set is added, we will be able
|
||||
// to conditionally support 16-bit NOPs
|
||||
if ((Count % 4) != 0)
|
||||
return false;
|
||||
|
||||
// The canonical nop on RISC-V is addi x0, x0, 0
|
||||
for (uint64_t i = 0; i < Count; i += 4)
|
||||
OW->write32(0x13);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
|
||||
MCContext &Ctx) {
|
||||
unsigned Kind = Fixup.getKind();
|
||||
switch (Kind) {
|
||||
default:
|
||||
llvm_unreachable("Unknown fixup kind!");
|
||||
case FK_Data_1:
|
||||
case FK_Data_2:
|
||||
case FK_Data_4:
|
||||
case FK_Data_8:
|
||||
return Value;
|
||||
case RISCV::fixup_riscv_lo12_i:
|
||||
return Value & 0xfff;
|
||||
case RISCV::fixup_riscv_lo12_s:
|
||||
return (((Value >> 5) & 0x7f) << 25) | ((Value & 0x1f) << 7);
|
||||
case RISCV::fixup_riscv_hi20:
|
||||
case RISCV::fixup_riscv_pcrel_hi20:
|
||||
// Add 1 if bit 11 is 1, to compensate for low 12 bits being negative.
|
||||
return ((Value + 0x800) >> 12) & 0xfffff;
|
||||
case RISCV::fixup_riscv_jal: {
|
||||
if (!isInt<21>(Value))
|
||||
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
|
||||
if (Value & 0x1)
|
||||
Ctx.reportError(Fixup.getLoc(), "fixup value must be 2-byte aligned");
|
||||
// Need to produce imm[19|10:1|11|19:12] from the 21-bit Value.
|
||||
unsigned Sbit = (Value >> 20) & 0x1;
|
||||
unsigned Hi8 = (Value >> 12) & 0xff;
|
||||
unsigned Mid1 = (Value >> 11) & 0x1;
|
||||
unsigned Lo10 = (Value >> 1) & 0x3ff;
|
||||
// Inst{31} = Sbit;
|
||||
// Inst{30-21} = Lo10;
|
||||
// Inst{20} = Mid1;
|
||||
// Inst{19-12} = Hi8;
|
||||
Value = (Sbit << 19) | (Lo10 << 9) | (Mid1 << 8) | Hi8;
|
||||
return Value;
|
||||
}
|
||||
case RISCV::fixup_riscv_branch: {
|
||||
if (!isInt<13>(Value))
|
||||
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
|
||||
if (Value & 0x1)
|
||||
Ctx.reportError(Fixup.getLoc(), "fixup value must be 2-byte aligned");
|
||||
// Need to extract imm[12], imm[10:5], imm[4:1], imm[11] from the 13-bit
|
||||
// Value.
|
||||
unsigned Sbit = (Value >> 12) & 0x1;
|
||||
unsigned Hi1 = (Value >> 11) & 0x1;
|
||||
unsigned Mid6 = (Value >> 5) & 0x3f;
|
||||
unsigned Lo4 = (Value >> 1) & 0xf;
|
||||
// Inst{31} = Sbit;
|
||||
// Inst{30-25} = Mid6;
|
||||
// Inst{11-8} = Lo4;
|
||||
// Inst{7} = Hi1;
|
||||
Value = (Sbit << 31) | (Mid6 << 25) | (Lo4 << 8) | (Hi1 << 7);
|
||||
return Value;
|
||||
}
|
||||
case RISCV::fixup_riscv_rvc_jump: {
|
||||
// Need to produce offset[11|4|9:8|10|6|7|3:1|5] from the 11-bit Value.
|
||||
unsigned Bit11 = (Value >> 11) & 0x1;
|
||||
unsigned Bit4 = (Value >> 4) & 0x1;
|
||||
unsigned Bit9_8 = (Value >> 8) & 0x3;
|
||||
unsigned Bit10 = (Value >> 10) & 0x1;
|
||||
unsigned Bit6 = (Value >> 6) & 0x1;
|
||||
unsigned Bit7 = (Value >> 7) & 0x1;
|
||||
unsigned Bit3_1 = (Value >> 1) & 0x7;
|
||||
unsigned Bit5 = (Value >> 5) & 0x1;
|
||||
Value = (Bit11 << 10) | (Bit4 << 9) | (Bit9_8 << 7) | (Bit10 << 6) |
|
||||
(Bit6 << 5) | (Bit7 << 4) | (Bit3_1 << 1) | Bit5;
|
||||
return Value;
|
||||
}
|
||||
case RISCV::fixup_riscv_rvc_branch: {
|
||||
// Need to produce offset[8|4:3], [reg 3 bit], offset[7:6|2:1|5]
|
||||
unsigned Bit8 = (Value >> 8) & 0x1;
|
||||
unsigned Bit7_6 = (Value >> 6) & 0x3;
|
||||
unsigned Bit5 = (Value >> 5) & 0x1;
|
||||
unsigned Bit4_3 = (Value >> 3) & 0x3;
|
||||
unsigned Bit2_1 = (Value >> 1) & 0x3;
|
||||
Value = (Bit8 << 12) | (Bit4_3 << 10) | (Bit7_6 << 5) | (Bit2_1 << 3) |
|
||||
(Bit5 << 2);
|
||||
return Value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned getSize(unsigned Kind) {
|
||||
switch (Kind) {
|
||||
default:
|
||||
return 4;
|
||||
case RISCV::fixup_riscv_rvc_jump:
|
||||
case RISCV::fixup_riscv_rvc_branch:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
void RISCVAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
|
||||
const MCValue &Target,
|
||||
MutableArrayRef<char> Data, uint64_t Value,
|
||||
bool IsResolved) const {
|
||||
MCContext &Ctx = Asm.getContext();
|
||||
MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
|
||||
if (!Value)
|
||||
return; // Doesn't change encoding.
|
||||
// Apply any target-specific value adjustments.
|
||||
Value = adjustFixupValue(Fixup, Value, Ctx);
|
||||
|
||||
// Shift the value into position.
|
||||
Value <<= Info.TargetOffset;
|
||||
|
||||
unsigned Offset = Fixup.getOffset();
|
||||
unsigned FullSize = getSize(Fixup.getKind());
|
||||
|
||||
#ifndef NDEBUG
|
||||
unsigned NumBytes = (Info.TargetSize + 7) / 8;
|
||||
assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
|
||||
#endif
|
||||
|
||||
// For each byte of the fragment that the fixup touches, mask in the
|
||||
// bits from the fixup value.
|
||||
for (unsigned i = 0; i != FullSize; ++i) {
|
||||
Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<MCObjectWriter>
|
||||
RISCVAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
|
||||
return createRISCVELFObjectWriter(OS, OSABI, Is64Bit);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
MCAsmBackend *llvm::createRISCVAsmBackend(const Target &T,
|
||||
const MCSubtargetInfo &STI,
|
||||
const MCRegisterInfo &MRI,
|
||||
const MCTargetOptions &Options) {
|
||||
const Triple &TT = STI.getTargetTriple();
|
||||
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
|
||||
return new RISCVAsmBackend(OSABI, TT.isArch64Bit());
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
//===-- RISCVBaseInfo.h - Top level definitions for RISCV MC ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains small standalone enum definitions for the RISCV target
|
||||
// useful for the compiler back-end and the MC libraries.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
|
||||
#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
|
||||
|
||||
#include "RISCVMCTargetDesc.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
// RISCVII - This namespace holds all of the target specific flags that
|
||||
// instruction info tracks. All definitions must match RISCVInstrFormats.td.
|
||||
namespace RISCVII {
|
||||
enum {
|
||||
InstFormatPseudo = 0,
|
||||
InstFormatR = 1,
|
||||
InstFormatR4 = 2,
|
||||
InstFormatI = 3,
|
||||
InstFormatS = 4,
|
||||
InstFormatB = 5,
|
||||
InstFormatU = 6,
|
||||
InstFormatJ = 7,
|
||||
InstFormatCR = 8,
|
||||
InstFormatCI = 9,
|
||||
InstFormatCSS = 10,
|
||||
InstFormatCIW = 11,
|
||||
InstFormatCL = 12,
|
||||
InstFormatCS = 13,
|
||||
InstFormatCB = 14,
|
||||
InstFormatCJ = 15,
|
||||
InstFormatOther = 16,
|
||||
|
||||
InstFormatMask = 31
|
||||
};
|
||||
|
||||
enum {
|
||||
MO_None,
|
||||
MO_LO,
|
||||
MO_HI,
|
||||
MO_PCREL_HI,
|
||||
};
|
||||
} // namespace RISCVII
|
||||
|
||||
// Describes the predecessor/successor bits used in the FENCE instruction.
|
||||
namespace RISCVFenceField {
|
||||
enum FenceField {
|
||||
I = 8,
|
||||
O = 4,
|
||||
R = 2,
|
||||
W = 1
|
||||
};
|
||||
}
|
||||
|
||||
// Describes the supported floating point rounding mode encodings.
|
||||
namespace RISCVFPRndMode {
|
||||
enum RoundingMode {
|
||||
RNE = 0,
|
||||
RTZ = 1,
|
||||
RDN = 2,
|
||||
RUP = 3,
|
||||
RMM = 4,
|
||||
DYN = 7,
|
||||
Invalid
|
||||
};
|
||||
|
||||
inline static StringRef roundingModeToString(RoundingMode RndMode) {
|
||||
switch (RndMode) {
|
||||
default:
|
||||
llvm_unreachable("Unknown floating point rounding mode");
|
||||
case RISCVFPRndMode::RNE:
|
||||
return "rne";
|
||||
case RISCVFPRndMode::RTZ:
|
||||
return "rtz";
|
||||
case RISCVFPRndMode::RDN:
|
||||
return "rdn";
|
||||
case RISCVFPRndMode::RUP:
|
||||
return "rup";
|
||||
case RISCVFPRndMode::RMM:
|
||||
return "rmm";
|
||||
case RISCVFPRndMode::DYN:
|
||||
return "dyn";
|
||||
}
|
||||
}
|
||||
|
||||
inline static RoundingMode stringToRoundingMode(StringRef Str) {
|
||||
return StringSwitch<RoundingMode>(Str)
|
||||
.Case("rne", RISCVFPRndMode::RNE)
|
||||
.Case("rtz", RISCVFPRndMode::RTZ)
|
||||
.Case("rdn", RISCVFPRndMode::RDN)
|
||||
.Case("rup", RISCVFPRndMode::RUP)
|
||||
.Case("rmm", RISCVFPRndMode::RMM)
|
||||
.Case("dyn", RISCVFPRndMode::DYN)
|
||||
.Default(RISCVFPRndMode::Invalid);
|
||||
}
|
||||
} // namespace RISCVFPRndMode
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
@ -1,75 +0,0 @@
|
||||
//===-- RISCVELFObjectWriter.cpp - RISCV ELF Writer -----------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/RISCVFixupKinds.h"
|
||||
#include "MCTargetDesc/RISCVMCTargetDesc.h"
|
||||
#include "llvm/MC/MCELFObjectWriter.h"
|
||||
#include "llvm/MC/MCFixup.h"
|
||||
#include "llvm/MC/MCObjectWriter.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class RISCVELFObjectWriter : public MCELFObjectTargetWriter {
|
||||
public:
|
||||
RISCVELFObjectWriter(uint8_t OSABI, bool Is64Bit);
|
||||
|
||||
~RISCVELFObjectWriter() override;
|
||||
|
||||
protected:
|
||||
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||
const MCFixup &Fixup, bool IsPCRel) const override;
|
||||
};
|
||||
}
|
||||
|
||||
RISCVELFObjectWriter::RISCVELFObjectWriter(uint8_t OSABI, bool Is64Bit)
|
||||
: MCELFObjectTargetWriter(Is64Bit, OSABI, ELF::EM_RISCV,
|
||||
/*HasRelocationAddend*/ true) {}
|
||||
|
||||
RISCVELFObjectWriter::~RISCVELFObjectWriter() {}
|
||||
|
||||
unsigned RISCVELFObjectWriter::getRelocType(MCContext &Ctx,
|
||||
const MCValue &Target,
|
||||
const MCFixup &Fixup,
|
||||
bool IsPCRel) const {
|
||||
// Determine the type of the relocation
|
||||
switch ((unsigned)Fixup.getKind()) {
|
||||
default:
|
||||
llvm_unreachable("invalid fixup kind!");
|
||||
case FK_Data_4:
|
||||
return ELF::R_RISCV_32;
|
||||
case FK_Data_8:
|
||||
return ELF::R_RISCV_64;
|
||||
case RISCV::fixup_riscv_hi20:
|
||||
return ELF::R_RISCV_HI20;
|
||||
case RISCV::fixup_riscv_lo12_i:
|
||||
return ELF::R_RISCV_LO12_I;
|
||||
case RISCV::fixup_riscv_lo12_s:
|
||||
return ELF::R_RISCV_LO12_S;
|
||||
case RISCV::fixup_riscv_pcrel_hi20:
|
||||
return ELF::R_RISCV_PCREL_HI20;
|
||||
case RISCV::fixup_riscv_jal:
|
||||
return ELF::R_RISCV_JAL;
|
||||
case RISCV::fixup_riscv_branch:
|
||||
return ELF::R_RISCV_BRANCH;
|
||||
case RISCV::fixup_riscv_rvc_jump:
|
||||
return ELF::R_RISCV_RVC_JUMP;
|
||||
case RISCV::fixup_riscv_rvc_branch:
|
||||
return ELF::R_RISCV_RVC_BRANCH;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<MCObjectWriter>
|
||||
llvm::createRISCVELFObjectWriter(raw_pwrite_stream &OS, uint8_t OSABI,
|
||||
bool Is64Bit) {
|
||||
return createELFObjectWriter(
|
||||
llvm::make_unique<RISCVELFObjectWriter>(OSABI, Is64Bit), OS,
|
||||
/*IsLittleEndian=*/true);
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
//===-- RISCVFixupKinds.h - RISCV Specific Fixup Entries --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVFIXUPKINDS_H
|
||||
#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVFIXUPKINDS_H
|
||||
|
||||
#include "llvm/MC/MCFixup.h"
|
||||
|
||||
#undef RISCV
|
||||
|
||||
namespace llvm {
|
||||
namespace RISCV {
|
||||
enum Fixups {
|
||||
// fixup_riscv_hi20 - 20-bit fixup corresponding to hi(foo) for
|
||||
// instructions like lui
|
||||
fixup_riscv_hi20 = FirstTargetFixupKind,
|
||||
// fixup_riscv_lo12_i - 12-bit fixup corresponding to lo(foo) for
|
||||
// instructions like addi
|
||||
fixup_riscv_lo12_i,
|
||||
// fixup_riscv_lo12_s - 12-bit fixup corresponding to lo(foo) for
|
||||
// the S-type store instructions
|
||||
fixup_riscv_lo12_s,
|
||||
// fixup_riscv_pcrel_hi20 - 20-bit fixup corresponding to pcrel_hi(foo) for
|
||||
// instructions like auipc
|
||||
fixup_riscv_pcrel_hi20,
|
||||
// fixup_riscv_jal - 20-bit fixup for symbol references in the jal
|
||||
// instruction
|
||||
fixup_riscv_jal,
|
||||
// fixup_riscv_branch - 12-bit fixup for symbol references in the branch
|
||||
// instructions
|
||||
fixup_riscv_branch,
|
||||
// fixup_riscv_rvc_jump - 11-bit fixup for symbol references in the
|
||||
// compressed jump instruction
|
||||
fixup_riscv_rvc_jump,
|
||||
// fixup_riscv_rvc_branch - 8-bit fixup for symbol references in the
|
||||
// compressed branch instruction
|
||||
fixup_riscv_rvc_branch,
|
||||
|
||||
// fixup_riscv_invalid - used as a sentinel and a marker, must be last fixup
|
||||
fixup_riscv_invalid,
|
||||
NumTargetFixupKinds = fixup_riscv_invalid - FirstTargetFixupKind
|
||||
};
|
||||
} // end namespace RISCV
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
//===-- RISCVMCAsmInfo.cpp - RISCV Asm properties -------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the declarations of the RISCVMCAsmInfo properties.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "RISCVMCAsmInfo.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
using namespace llvm;
|
||||
|
||||
void RISCVMCAsmInfo::anchor() {}
|
||||
|
||||
RISCVMCAsmInfo::RISCVMCAsmInfo(const Triple &TT) {
|
||||
CodePointerSize = CalleeSaveStackSlotSize = TT.isArch64Bit() ? 8 : 4;
|
||||
CommentString = "#";
|
||||
AlignmentIsInBytes = false;
|
||||
SupportsDebugInformation = true;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
//===-- RISCVMCAsmInfo.h - RISCV Asm Info ----------------------*- C++ -*--===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the declaration of the RISCVMCAsmInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H
|
||||
#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H
|
||||
|
||||
#include "llvm/MC/MCAsmInfoELF.h"
|
||||
|
||||
namespace llvm {
|
||||
class Triple;
|
||||
|
||||
class RISCVMCAsmInfo : public MCAsmInfoELF {
|
||||
void anchor() override;
|
||||
|
||||
public:
|
||||
explicit RISCVMCAsmInfo(const Triple &TargetTriple);
|
||||
};
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user