Skip to content
Permalink
Browse files

Partially support MO_LOLO and MO_LOHI target flags

  • Loading branch information...
reSHARMA committed Jul 31, 2019
1 parent 6dbaa4b commit 95ecd051e2b65482b860d697bd1aaa6c63e196ad
Showing with 22 additions and 0 deletions.
  1. +12 −0 MCTargetDesc/RISCVMCExpr.cpp
  2. +2 −0 MCTargetDesc/RISCVMCExpr.h
  3. +6 −0 RISCVMCInstLower.cpp
  4. +2 −0 Utils/RISCVBaseInfo.h
@@ -135,6 +135,8 @@ bool RISCVMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
return true;
case VK_RISCV_LO:
case VK_RISCV_HI:
case VK_RISCV_LOHI:
case VK_RISCV_LOLO:
case VK_RISCV_PCREL_LO:
case VK_RISCV_PCREL_HI:
return false;
@@ -152,6 +154,8 @@ RISCVMCExpr::VariantKind RISCVMCExpr::getVariantKindForName(StringRef name) {
return StringSwitch<RISCVMCExpr::VariantKind>(name)
.Case("lo", VK_RISCV_LO)
.Case("hi", VK_RISCV_HI)
.Case("lohi", VK_RISCV_LOHI)
.Case("lolo", VK_RISCV_LOLO)
.Case("pcrel_lo", VK_RISCV_PCREL_LO)
.Case("pcrel_hi", VK_RISCV_PCREL_HI)
.Default(VK_RISCV_Invalid);
@@ -165,6 +169,10 @@ StringRef RISCVMCExpr::getVariantKindName(VariantKind Kind) {
return "lo";
case VK_RISCV_HI:
return "hi";
case VK_RISCV_LOHI:
return "lohi";
case VK_RISCV_LOLO:
return "lolo";
case VK_RISCV_PCREL_LO:
return "pcrel_lo";
case VK_RISCV_PCREL_HI:
@@ -198,5 +206,9 @@ int64_t RISCVMCExpr::evaluateAsInt64(int64_t Value) const {
case VK_RISCV_HI:
// Add 1 if bit 11 is 1, to compensate for low 12 bits being negative.
return ((Value + 0x800) >> 12) & 0xfffff;
case VK_RISCV_LOHI:
return (((Value << 32) + 0x800) >> 12) & 0xfffff;
case VK_RISCV_LOLO:
return SignExtend64<12>(Value << 32);
}
}
@@ -27,6 +27,8 @@ class RISCVMCExpr : public MCTargetExpr {
VK_RISCV_None,
VK_RISCV_LO,
VK_RISCV_HI,
VK_RISCV_LOLO,
VK_RISCV_LOHI,
VK_RISCV_PCREL_LO,
VK_RISCV_PCREL_HI,
VK_RISCV_CALL,
@@ -43,6 +43,12 @@ static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
case RISCVII::MO_HI:
Kind = RISCVMCExpr::VK_RISCV_HI;
break;
case RISCVII::MO_LOHI:
Kind = RISCVMCExpr::VK_RISCV_LOHI;
break;
case RISCVII::MO_LOLO:
Kind = RISCVMCExpr::VK_RISCV_LOLO;
break;
}

const MCExpr *ME =
@@ -51,6 +51,8 @@ enum {
MO_None,
MO_LO,
MO_HI,
MO_LOHI,
MO_LOLO,
MO_PCREL_HI,
};
} // namespace RISCVII

0 comments on commit 95ecd05

Please sign in to comment.
You can’t perform that action at this time.