31 bool ShouldForce =
false;
33 switch ((
unsigned)Fixup.
getKind()) {
43 "could not find corresponding %pcrel_hi");
47 switch ((
unsigned)T->
getKind()) {
68 const bool WasForced)
const {
73 if (!Resolved && !WasForced)
76 int64_t
Offset = int64_t(Value);
77 switch ((
unsigned)Fixup.
getKind()) {
83 return Offset > 254 || Offset < -256;
87 return Offset > 2046 || Offset < -2048;
150 unsigned MinNopLen = HasStdExtC ? 2 : 4;
152 if ((Count % MinNopLen) != 0)
156 uint64_t Nop32Count = Count / 4;
157 for (uint64_t i = Nop32Count; i != 0; --i)
158 OS.
write(
"\x13\0\0\0", 4);
162 uint64_t Nop16Count = (Count - Nop32Count * 4) / 2;
163 for (uint64_t i = Nop16Count; i != 0; --i)
164 OS.
write(
"\x01\0", 2);
183 return Value & 0xfff;
186 return (((Value >> 5) & 0x7f) << 25) | ((Value & 0x1f) << 7);
190 return ((Value + 0x800) >> 12) & 0xfffff;
192 if (!isInt<21>(Value))
197 unsigned Sbit = (Value >> 20) & 0x1;
198 unsigned Hi8 = (Value >> 12) & 0xff;
199 unsigned Mid1 = (Value >> 11) & 0x1;
200 unsigned Lo10 = (Value >> 1) & 0x3ff;
205 Value = (Sbit << 19) | (Lo10 << 9) | (Mid1 << 8) | Hi8;
209 if (!isInt<13>(Value))
215 unsigned Sbit = (Value >> 12) & 0x1;
216 unsigned Hi1 = (Value >> 11) & 0x1;
217 unsigned Mid6 = (Value >> 5) & 0x3f;
218 unsigned Lo4 = (Value >> 1) & 0xf;
223 Value = (Sbit << 31) | (Mid6 << 25) | (Lo4 << 8) | (Hi1 << 7);
230 uint64_t UpperImm = (Value + 0x800ULL) & 0xfffff000ULL;
231 uint64_t LowerImm = Value & 0xfffULL;
232 return UpperImm | ((LowerImm << 20) << 32);
236 unsigned Bit11 = (Value >> 11) & 0x1;
237 unsigned Bit4 = (Value >> 4) & 0x1;
238 unsigned Bit9_8 = (Value >> 8) & 0x3;
239 unsigned Bit10 = (Value >> 10) & 0x1;
240 unsigned Bit6 = (Value >> 6) & 0x1;
241 unsigned Bit7 = (Value >> 7) & 0x1;
242 unsigned Bit3_1 = (Value >> 1) & 0x7;
243 unsigned Bit5 = (Value >> 5) & 0x1;
244 Value = (Bit11 << 10) | (Bit4 << 9) | (Bit9_8 << 7) | (Bit10 << 6) |
245 (Bit6 << 5) | (Bit7 << 4) | (Bit3_1 << 1) | Bit5;
250 unsigned Bit8 = (Value >> 8) & 0x1;
251 unsigned Bit7_6 = (Value >> 6) & 0x3;
252 unsigned Bit5 = (Value >> 5) & 0x1;
253 unsigned Bit4_3 = (Value >> 3) & 0x3;
254 unsigned Bit2_1 = (Value >> 1) & 0x3;
255 Value = (Bit8 << 12) | (Bit4_3 << 10) | (Bit7_6 << 5) | (Bit2_1 << 3) |
281 assert(Offset + NumBytes <= Data.
size() &&
"Invalid fixup offset!");
285 for (
unsigned i = 0; i != NumBytes; ++i) {
286 Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
290 std::unique_ptr<MCObjectTargetWriter>
std::unique_ptr< MCObjectTargetWriter > createRISCVELFObjectWriter(uint8_t OSABI, bool Is64Bit)
MCAsmBackend * createRISCVAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
This class represents lattice values for constants.
This represents an "assembler immediate".
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
bool fixupNeedsRelaxationAdvanced(const MCFixup &Fixup, bool Resolved, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout, const bool WasForced) const override
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed...
unsigned TargetOffset
The bit offset to write the relocation into.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const Triple & getTargetTriple() const
MCContext & getContext() const
static MCOperand createReg(unsigned Reg)
const FeatureBitset & getFeatureBits() const
Encapsulates the layout of an assembly file at a particular point in time.
This file implements a class to represent arbitrary precision integral constant values and operations...
RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit)
Context object for machine code objects.
unsigned getRelaxedOpcode(unsigned Op) const
bool writeNopData(raw_ostream &OS, uint64_t Count) const override
Write an (optimal) nop sequence of Count bytes to the given output.
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
unsigned const MachineRegisterInfo * MRI
static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value, MCContext &Ctx)
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
size_t size() const
size - Get the array size.
void reportError(SMLoc L, const Twine &Msg)
uint32_t getOffset() const
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
raw_ostream & write(unsigned char C)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
unsigned TargetSize
The number of bits written by this fixup.
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Target - Wrapper for Target specific information.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Generic base class for all target subtargets.
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const override
Relax the instruction in the given fragment to the next wider instruction.
Target independent information on a fixup kind.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Generic interface to target specific assembler backends.
This class implements an extremely fast bulk output stream that can only output to a stream...
const MCExpr * getValue() const
void addOperand(const MCOperand &Op)
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) override
Hook to check if a relocation is needed for some target specific reason.
bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override
Check whether the given instruction may need relaxation.
unsigned getOpcode() const
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
MCFixupKind getKind() const