diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /llvm/lib/Target/Sparc/Disassembler | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'llvm/lib/Target/Sparc/Disassembler')
| -rw-r--r-- | llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp | 91 |
1 files changed, 40 insertions, 51 deletions
diff --git a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp index f1cd9b1ab07c..c3d60f3689e1 100644 --- a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp +++ b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp @@ -266,16 +266,47 @@ DecodeCoprocPairRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, return MCDisassembler::Success; } -static DecodeStatus DecodeCall(MCInst &Inst, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder); -static DecodeStatus DecodeSIMM5(MCInst &Inst, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder); -static DecodeStatus DecodeSIMM13(MCInst &Inst, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder); +static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch, + uint64_t Address, uint64_t Offset, + uint64_t Width, MCInst &MI, + const MCDisassembler *Decoder) { + return Decoder->tryAddingSymbolicOperand(MI, Value, Address, isBranch, Offset, + Width, /*InstSize=*/4); +} + +static DecodeStatus DecodeCall(MCInst &MI, unsigned insn, uint64_t Address, + const MCDisassembler *Decoder) { + int64_t CallOffset = SignExtend64(fieldFromInstruction(insn, 0, 30), 30) * 4; + if (!tryAddingSymbolicOperand(Address + CallOffset, false, Address, 0, 30, MI, + Decoder)) + MI.addOperand(MCOperand::createImm(CallOffset)); + return MCDisassembler::Success; +} + +static DecodeStatus DecodeSIMM5(MCInst &MI, unsigned insn, uint64_t Address, + const MCDisassembler *Decoder) { + assert(isUInt<5>(insn)); + MI.addOperand(MCOperand::createImm(SignExtend64<5>(insn))); + return MCDisassembler::Success; +} + +static DecodeStatus DecodeSIMM13(MCInst &MI, unsigned insn, uint64_t Address, + const MCDisassembler *Decoder) { + assert(isUInt<13>(insn)); + MI.addOperand(MCOperand::createImm(SignExtend64<13>(insn))); + return MCDisassembler::Success; +} + template <unsigned N> -constexpr static DecodeStatus DecodeDisp(MCInst &MI, uint32_t ImmVal, - uint64_t Address, - const MCDisassembler *Decoder); +static DecodeStatus DecodeDisp(MCInst &MI, uint32_t ImmVal, uint64_t Address, + const MCDisassembler *Decoder) { + int64_t BranchOffset = SignExtend64(ImmVal, N) * 4; + if (!tryAddingSymbolicOperand(Address + BranchOffset, true, Address, 0, N, MI, + Decoder)) + MI.addOperand(MCOperand::createImm(BranchOffset)); + return MCDisassembler::Success; +} + #include "SparcGenDisassemblerTables.inc" /// Read four bytes from the ArrayRef and return 32 bit word. @@ -321,45 +352,3 @@ DecodeStatus SparcDisassembler::getInstruction(MCInst &Instr, uint64_t &Size, return Result; } - -static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch, - uint64_t Address, uint64_t Offset, - uint64_t Width, MCInst &MI, - const MCDisassembler *Decoder) { - return Decoder->tryAddingSymbolicOperand(MI, Value, Address, isBranch, Offset, - Width, /*InstSize=*/4); -} - -static DecodeStatus DecodeCall(MCInst &MI, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder) { - int64_t CallOffset = SignExtend64(fieldFromInstruction(insn, 0, 30), 30) * 4; - if (!tryAddingSymbolicOperand(Address + CallOffset, false, Address, 0, 30, MI, - Decoder)) - MI.addOperand(MCOperand::createImm(CallOffset)); - return MCDisassembler::Success; -} - -static DecodeStatus DecodeSIMM5(MCInst &MI, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder) { - assert(isUInt<5>(insn)); - MI.addOperand(MCOperand::createImm(SignExtend64<5>(insn))); - return MCDisassembler::Success; -} - -static DecodeStatus DecodeSIMM13(MCInst &MI, unsigned insn, uint64_t Address, - const MCDisassembler *Decoder) { - assert(isUInt<13>(insn)); - MI.addOperand(MCOperand::createImm(SignExtend64<13>(insn))); - return MCDisassembler::Success; -} - -template <unsigned N> -constexpr static DecodeStatus DecodeDisp(MCInst &MI, uint32_t ImmVal, - uint64_t Address, - const MCDisassembler *Decoder) { - int64_t BranchOffset = SignExtend64(ImmVal, N) * 4; - if (!tryAddingSymbolicOperand(Address + BranchOffset, true, Address, 0, N, MI, - Decoder)) - MI.addOperand(MCOperand::createImm(BranchOffset)); - return MCDisassembler::Success; -} |
