Skip to content

Commit

Permalink
Add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Dec 22, 2023
1 parent a75aae5 commit 26e1bbe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions llvm/lib/Target/SBF/MCTargetDesc/SBFMCCodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ unsigned SBFMCCodeEmitter::getMachineOpValue(const MCInst &MI,
else if (MI.getOpcode() == SBF::LD_imm64 ||
MI.getOpcode() == SBF::MOV_32_64_addr)
Fixups.push_back(MCFixup::create(0, Expr, FK_SecRel_8));
else if (MI.getOpcode() == SBF::HOR_addr) {
// This is already handled in MOV_32_64
} else
// In SBFv2, LD_imm64 is replaced by MOV_32_64_addr and HOR_addr when loading
// addresses. These two instructions always appear together, so if a
// relocation is necessary, we only insert it for one of them, in this case
// MOV_32_64.
else if (MI.getOpcode() != SBF::HOR_addr)
// bb label
Fixups.push_back(MCFixup::create(0, Expr, FK_PCRel_2));

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/SBF/SBFInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def i32immSExt32 : PatLeaf<(i32 imm),
[{return isInt<32>(N->getSExtValue()); }]>;

// Fetch the upper 32-bits of a 64-bit integer.
def Upper64 : SDNodeXForm<imm, [{
def Upper32 : SDNodeXForm<imm, [{
uint64_t value = N->getSExtValue() >> 32;
return CurDAG->getTargetConstant(value, SDLoc(N),
N->getValueType(0));
}]>;

// Fetch the lower 32-bits of a 64-bit integer.
def Lower64 : SDNodeXForm<imm, [{
def Lower32 : SDNodeXForm<imm, [{
uint64_t value = N->getSExtValue() & 0x00000000ffffffff;
return CurDAG->getTargetConstant(value, SDLoc(N),
N->getValueType(0));
Expand Down Expand Up @@ -985,8 +985,8 @@ let isCodeGenOnly = 1 in {
// hor r1, 0x11223344
// These instructions copy the value 0x1122334455667788 to a register.
def : Pat<(i64 imm:$imm),
(HOR (MOV_32_64_imm (i32 (Lower64 $imm))),
(i32 (Upper64 $imm)))>, Requires<[SBFv2]>;
(HOR (MOV_32_64_imm (i32 (Lower32 $imm))),
(i32 (Upper32 $imm)))>, Requires<[SBFv2]>;

// load 64-bit global address into register.
def : Pat<(SBFWrapper tglobaladdr:$in), (LD_imm64 tglobaladdr:$in)>,
Expand Down

0 comments on commit 26e1bbe

Please sign in to comment.