Skip to content

Commit 4674083

Browse files
committed
Remove symbol parsing support for gp-related instruction
1 parent 347384f commit 4674083

File tree

10 files changed

+109
-201
lines changed

10 files changed

+109
-201
lines changed

llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV_nonstandard.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,3 @@ ELF_RISCV_NONSTANDARD_RELOC(QUALCOMM, R_RISCV_QC_E_CALL_PLT, 195)
2929

3030
// Andes Nonstandard Relocations
3131
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_BRANCH_10, 241)
32-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_18S0_I, 246)
33-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S1_I, 247)
34-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S2_I, 248)
35-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S3_I, 249)
36-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_18S0_S, 250)
37-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S1_S, 251)
38-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S2_S, 252)
39-
ELF_RISCV_NONSTANDARD_RELOC(ANDES, R_RISCV_NDS_GPREL_17S3_S, 253)

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,14 @@ struct RISCVOperand final : public MCParsedAsmOperand {
534534
}
535535

536536
// True if operand is a symbol with no modifiers, or a constant with no
537-
// modifiers and isShiftedInt<N-K, K>(Op).
538-
template <int N, int K> bool isBareSimmNLsbK() const {
537+
// modifiers and isShiftedInt<N-1, 1>(Op).
538+
template <int N> bool isBareSimmNLsb0() const {
539539
if (!isImm())
540540
return false;
541541

542542
int64_t Imm;
543543
if (evaluateConstantImm(getImm(), Imm))
544-
return isShiftedInt<N - K, K>(fixImmediateForRV32(Imm, isRV64Imm()));
544+
return isShiftedInt<N - 1, 1>(fixImmediateForRV32(Imm, isRV64Imm()));
545545

546546
RISCV::Specifier VK = RISCV::S_None;
547547
return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -947,6 +947,22 @@ struct RISCVOperand final : public MCParsedAsmOperand {
947947
[](int64_t Imm) { return Imm != INT64_MIN && isInt<5>(Imm - 1); });
948948
}
949949

950+
bool isSImm18() const {
951+
return isSImmPred([](int64_t Imm) { return isInt<18>(Imm); });
952+
}
953+
954+
bool isSImm18Lsb0() const {
955+
return isSImmPred([](int64_t Imm) { return isShiftedInt<17, 1>(Imm); });
956+
}
957+
958+
bool isSImm19Lsb00() const {
959+
return isSImmPred([](int64_t Imm) { return isShiftedInt<17, 2>(Imm); });
960+
}
961+
962+
bool isSImm20Lsb000() const {
963+
return isSImmPred([](int64_t Imm) { return isShiftedInt<17, 3>(Imm); });
964+
}
965+
950966
bool isSImm32Lsb0() const {
951967
return isSImmPred([](int64_t Imm) { return isShiftedInt<31, 1>(Imm); });
952968
}
@@ -1603,18 +1619,18 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
16031619
(1 << 4),
16041620
"immediate must be in the range");
16051621
}
1606-
case Match_InvalidBareSImm18:
1622+
case Match_InvalidSImm18:
16071623
return generateImmOutOfRangeError(Operands, ErrorInfo, -(1 << 17),
16081624
(1 << 17) - 1);
1609-
case Match_InvalidBareSImm18Lsb0:
1625+
case Match_InvalidSImm18Lsb0:
16101626
return generateImmOutOfRangeError(
16111627
Operands, ErrorInfo, -(1 << 17), (1 << 17) - 2,
16121628
"immediate must be a multiple of 2 bytes in the range");
1613-
case Match_InvalidBareSImm19Lsb00:
1629+
case Match_InvalidSImm19Lsb00:
16141630
return generateImmOutOfRangeError(
16151631
Operands, ErrorInfo, -(1 << 18), (1 << 18) - 4,
16161632
"immediate must be a multiple of 4 bytes in the range");
1617-
case Match_InvalidBareSImm20Lsb000:
1633+
case Match_InvalidSImm20Lsb000:
16181634
return generateImmOutOfRangeError(
16191635
Operands, ErrorInfo, -(1 << 19), (1 << 19) - 8,
16201636
"immediate must be a multiple of 8 bytes in the range");

llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,12 @@ enum {
5757
InstFormatQC_EJ = 25,
5858
InstFormatQC_ES = 26,
5959
InstFormatNDS_BRANCH_10 = 27,
60-
InstFormatNDS_GPREL_18S0_I = 28,
61-
InstFormatNDS_GPREL_17S1_I = 29,
62-
InstFormatNDS_GPREL_17S2_I = 30,
63-
InstFormatNDS_GPREL_17S3_I = 31,
64-
InstFormatNDS_GPREL_18S0_S = 32,
65-
InstFormatNDS_GPREL_17S1_S = 33,
66-
InstFormatNDS_GPREL_17S2_S = 34,
67-
InstFormatNDS_GPREL_17S3_S = 35,
68-
InstFormatOther = 63,
69-
70-
InstFormatMask = 63,
60+
InstFormatOther = 31,
61+
62+
InstFormatMask = 31,
7163
InstFormatShift = 0,
7264

73-
ConstraintShift = InstFormatShift + 6,
65+
ConstraintShift = InstFormatShift + 5,
7466
VS2Constraint = 0b001 << ConstraintShift,
7567
VS1Constraint = 0b010 << ConstraintShift,
7668
VMConstraint = 0b100 << ConstraintShift,

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -649,22 +649,6 @@ uint64_t RISCVMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNo,
649649
RelaxCandidate = true;
650650
} else if (MIFrm == RISCVII::InstFormatNDS_BRANCH_10) {
651651
FixupKind = RISCV::fixup_riscv_nds_branch_10;
652-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_18S0_I) {
653-
FixupKind = ELF::R_RISCV_NDS_GPREL_18S0_I;
654-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S1_I) {
655-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S1_I;
656-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S2_I) {
657-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S2_I;
658-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S3_I) {
659-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S3_I;
660-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_18S0_S) {
661-
FixupKind = ELF::R_RISCV_NDS_GPREL_18S0_S;
662-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S1_S) {
663-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S1_S;
664-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S2_S) {
665-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S2_S;
666-
} else if (MIFrm == RISCVII::InstFormatNDS_GPREL_17S3_S) {
667-
FixupKind = ELF::R_RISCV_NDS_GPREL_17S3_S;
668652
}
669653
}
670654

llvm/lib/Target/RISCV/RISCVInstrFormats.td

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,38 @@
2727
// Format specifies the encoding used by the instruction. This is used by
2828
// RISCVMCCodeEmitter to determine which form of fixup to use. These
2929
// definitions must be kept in-sync with RISCVBaseInfo.h.
30-
class InstFormat<bits<6> val> {
31-
bits<6> Value = val;
32-
}
33-
def InstFormatPseudo : InstFormat<0>;
34-
def InstFormatR : InstFormat<1>;
35-
def InstFormatR4 : InstFormat<2>;
36-
def InstFormatI : InstFormat<3>;
37-
def InstFormatS : InstFormat<4>;
38-
def InstFormatB : InstFormat<5>;
39-
def InstFormatU : InstFormat<6>;
40-
def InstFormatJ : InstFormat<7>;
41-
def InstFormatCR : InstFormat<8>;
42-
def InstFormatCI : InstFormat<9>;
43-
def InstFormatCSS : InstFormat<10>;
44-
def InstFormatCIW : InstFormat<11>;
45-
def InstFormatCL : InstFormat<12>;
46-
def InstFormatCS : InstFormat<13>;
47-
def InstFormatCA : InstFormat<14>;
48-
def InstFormatCB : InstFormat<15>;
49-
def InstFormatCJ : InstFormat<16>;
50-
def InstFormatCU : InstFormat<17>;
51-
def InstFormatCLB : InstFormat<18>;
52-
def InstFormatCLH : InstFormat<19>;
53-
def InstFormatCSB : InstFormat<20>;
54-
def InstFormatCSH : InstFormat<21>;
55-
def InstFormatQC_EAI : InstFormat<22>;
56-
def InstFormatQC_EI : InstFormat<23>;
57-
def InstFormatQC_EB : InstFormat<24>;
58-
def InstFormatQC_EJ : InstFormat<25>;
59-
def InstFormatQC_ES : InstFormat<26>;
60-
def InstFormatNDS_BRANCH_10 : InstFormat<27>;
61-
def InstFormatNDS_GPREL_18S0_I : InstFormat<28>;
62-
def InstFormatNDS_GPREL_17S1_I : InstFormat<29>;
63-
def InstFormatNDS_GPREL_17S2_I : InstFormat<30>;
64-
def InstFormatNDS_GPREL_17S3_I : InstFormat<31>;
65-
def InstFormatNDS_GPREL_18S0_S : InstFormat<32>;
66-
def InstFormatNDS_GPREL_17S1_S : InstFormat<33>;
67-
def InstFormatNDS_GPREL_17S2_S : InstFormat<34>;
68-
def InstFormatNDS_GPREL_17S3_S : InstFormat<35>;
69-
def InstFormatOther : InstFormat<63>;
30+
class InstFormat<bits<5> val> {
31+
bits<5> Value = val;
32+
}
33+
def InstFormatPseudo : InstFormat<0>;
34+
def InstFormatR : InstFormat<1>;
35+
def InstFormatR4 : InstFormat<2>;
36+
def InstFormatI : InstFormat<3>;
37+
def InstFormatS : InstFormat<4>;
38+
def InstFormatB : InstFormat<5>;
39+
def InstFormatU : InstFormat<6>;
40+
def InstFormatJ : InstFormat<7>;
41+
def InstFormatCR : InstFormat<8>;
42+
def InstFormatCI : InstFormat<9>;
43+
def InstFormatCSS : InstFormat<10>;
44+
def InstFormatCIW : InstFormat<11>;
45+
def InstFormatCL : InstFormat<12>;
46+
def InstFormatCS : InstFormat<13>;
47+
def InstFormatCA : InstFormat<14>;
48+
def InstFormatCB : InstFormat<15>;
49+
def InstFormatCJ : InstFormat<16>;
50+
def InstFormatCU : InstFormat<17>;
51+
def InstFormatCLB : InstFormat<18>;
52+
def InstFormatCLH : InstFormat<19>;
53+
def InstFormatCSB : InstFormat<20>;
54+
def InstFormatCSH : InstFormat<21>;
55+
def InstFormatQC_EAI : InstFormat<22>;
56+
def InstFormatQC_EI : InstFormat<23>;
57+
def InstFormatQC_EB : InstFormat<24>;
58+
def InstFormatQC_EJ : InstFormat<25>;
59+
def InstFormatQC_ES : InstFormat<26>;
60+
def InstFormatNDS_BRANCH_10 : InstFormat<27>;
61+
def InstFormatOther : InstFormat<31>;
7062

7163

7264
class RISCVVConstraint<bits<3> val> {
@@ -201,50 +193,50 @@ class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
201193
let AsmString = opcodestr # !if(!empty(argstr), "", "\t" # argstr);
202194
let Pattern = pattern;
203195

204-
let TSFlags{5-0} = format.Value;
196+
let TSFlags{4-0} = format.Value;
205197

206198
// Defaults
207199
RISCVVConstraint RVVConstraint = NoConstraint;
208-
let TSFlags{8-6} = RVVConstraint.Value;
200+
let TSFlags{7-5} = RVVConstraint.Value;
209201

210202
bits<3> VLMul = 0;
211-
let TSFlags{11-9} = VLMul;
203+
let TSFlags{10-8} = VLMul;
212204

213205
bit IsTiedPseudo = 0;
214-
let TSFlags{12} = IsTiedPseudo;
206+
let TSFlags{11} = IsTiedPseudo;
215207

216208
bit HasSEWOp = 0;
217-
let TSFlags{13} = HasSEWOp;
209+
let TSFlags{12} = HasSEWOp;
218210

219211
bit HasVLOp = 0;
220-
let TSFlags{14} = HasVLOp;
212+
let TSFlags{13} = HasVLOp;
221213

222214
bit HasVecPolicyOp = 0;
223-
let TSFlags{15} = HasVecPolicyOp;
215+
let TSFlags{14} = HasVecPolicyOp;
224216

225217
bit IsRVVWideningReduction = 0;
226-
let TSFlags{16} = IsRVVWideningReduction;
218+
let TSFlags{15} = IsRVVWideningReduction;
227219

228220
bit UsesMaskPolicy = 0;
229-
let TSFlags{17} = UsesMaskPolicy;
221+
let TSFlags{16} = UsesMaskPolicy;
230222

231223
// Indicates that the result can be considered sign extended from bit 31. Some
232224
// instructions with this flag aren't W instructions, but are either sign
233225
// extended from a smaller size, always outputs a small integer, or put zeros
234226
// in bits 63:31. Used by the SExtWRemoval pass.
235227
bit IsSignExtendingOpW = 0;
236-
let TSFlags{18} = IsSignExtendingOpW;
228+
let TSFlags{17} = IsSignExtendingOpW;
237229

238230
bit HasRoundModeOp = 0;
239-
let TSFlags{19} = HasRoundModeOp;
231+
let TSFlags{18} = HasRoundModeOp;
240232

241233
// This is only valid when HasRoundModeOp is set to 1. HasRoundModeOp is set
242234
// to 1 for vector fixed-point or floating-point intrinsics. This bit is
243235
// processed under pass 'RISCVInsertReadWriteCSR' pass to distinguish between
244236
// fixed-point / floating-point instructions and emit appropriate read/write
245237
// to the correct CSR.
246238
bit UsesVXRM = 0;
247-
let TSFlags{20} = UsesVXRM;
239+
let TSFlags{19} = UsesVXRM;
248240

249241
// Indicates whether these instructions can partially overlap between source
250242
// registers and destination registers according to the vector spec.
@@ -253,19 +245,19 @@ class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
253245
// 2 -> narrowing case
254246
// 3 -> widening case
255247
bits<2> TargetOverlapConstraintType = 0;
256-
let TSFlags{22-21} = TargetOverlapConstraintType;
248+
let TSFlags{21-20} = TargetOverlapConstraintType;
257249

258250
// Most vector instructions are elementwise, but some may depend on the value
259251
// of VL (e.g. vslide1down.vx), and others may depend on the VL and mask
260252
// (e.g. vredsum.vs, viota.m). Mark these instructions so that peepholes avoid
261253
// changing their VL and/or mask.
262254
EltDeps ElementsDependOn = EltDepsNone;
263-
let TSFlags{23} = ElementsDependOn.VL;
264-
let TSFlags{24} = ElementsDependOn.Mask;
255+
let TSFlags{22} = ElementsDependOn.VL;
256+
let TSFlags{23} = ElementsDependOn.Mask;
265257

266258
// Indicates the EEW of a vector instruction's destination operand.
267259
EEW DestEEW = EEWSEWx1;
268-
let TSFlags{26-25} = DestEEW.Value;
260+
let TSFlags{25-24} = DestEEW.Value;
269261
}
270262

271263
class RVInst<dag outs, dag ins, string opcodestr, string argstr,

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,9 @@ class UImmAsmOperand<int width, string suffix = "">
227227
: ImmAsmOperand<"U", width, suffix> {
228228
}
229229

230-
class BareSImmNAsmOperand<int width>
231-
: ImmAsmOperand<"BareS", width, ""> {
232-
let PredicateMethod = "isBareSimmN<" # width # ">";
233-
}
234-
235230
class BareSImmNLsb0AsmOperand<int width>
236231
: ImmAsmOperand<"BareS", width, "Lsb0"> {
237-
let PredicateMethod = "isBareSimmNLsbK<" # width # ", 1>";
238-
}
239-
240-
class BareSImmNLsb00AsmOperand<int width>
241-
: ImmAsmOperand<"BareS", width, "Lsb00"> {
242-
let PredicateMethod = "isBareSimmNLsbK<" # width # ", 2>";
243-
}
244-
245-
class BareSImmNLsb000AsmOperand<int width>
246-
: ImmAsmOperand<"BareS", width, "Lsb000"> {
247-
let PredicateMethod = "isBareSimmNLsbK<" # width # ", 3>";
232+
let PredicateMethod = "isBareSimmNLsb0<" # width # ">";
248233
}
249234

250235
class RISCVOp<ValueType vt = XLenVT> : Operand<vt> {

0 commit comments

Comments
 (0)