llvm.org GIT mirror llvm / f2c8bbc
Merging r369097: ------------------------------------------------------------------------ r369097 | lewis-revill | 2019-08-16 14:00:56 +0200 (Fri, 16 Aug 2019) | 8 lines [RISCV] Allow parsing of bare symbols with offsets This patch allows symbols followed by an expression for an offset to be parsed as bare symbols. Differential Revision: https://reviews.llvm.org/D57332 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@369338 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 3 months ago
2 changed file(s) with 87 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
12071207 Res = V;
12081208 } else
12091209 Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, getContext());
1210
1211 MCBinaryExpr::Opcode Opcode;
1212 switch (getLexer().getKind()) {
1213 default:
1214 Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64()));
1215 return MatchOperand_Success;
1216 case AsmToken::Plus:
1217 Opcode = MCBinaryExpr::Add;
1218 break;
1219 case AsmToken::Minus:
1220 Opcode = MCBinaryExpr::Sub;
1221 break;
1222 }
1223
1224 const MCExpr *Expr;
1225 if (getParser().parseExpression(Expr))
1226 return MatchOperand_ParseFail;
1227 Res = MCBinaryExpr::create(Opcode, Res, Expr, getContext());
12101228 Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64()));
12111229 return MatchOperand_Success;
12121230 }
3333 lla a4, f1
3434
3535 # CHECK: .Lpcrel_hi5:
36 # CHECK: auipc a5, %pcrel_hi(a_symbol+2040)
37 # CHECK: addi a5, a5, %pcrel_lo(.Lpcrel_hi5)
38 lla a5, a_symbol + (0xFF << 3)
39
40 # CHECK: .Lpcrel_hi6:
3641 # CHECK-NOPIC: auipc a0, %pcrel_hi(a_symbol)
37 # CHECK-NOPIC: addi a0, a0, %pcrel_lo(.Lpcrel_hi5)
42 # CHECK-NOPIC: addi a0, a0, %pcrel_lo(.Lpcrel_hi6)
3843 # CHECK-PIC: auipc a0, %got_pcrel_hi(a_symbol)
39 # CHECK-PIC-RV32: lw a0, %pcrel_lo(.Lpcrel_hi5)(a0)
40 # CHECK-PIC-RV64: ld a0, %pcrel_lo(.Lpcrel_hi5)(a0)
44 # CHECK-PIC-RV32: lw a0, %pcrel_lo(.Lpcrel_hi6)(a0)
45 # CHECK-PIC-RV64: ld a0, %pcrel_lo(.Lpcrel_hi6)(a0)
4146 la a0, a_symbol
4247
43 # CHECK: .Lpcrel_hi6:
48 # CHECK: .Lpcrel_hi7:
4449 # CHECK-NOPIC: auipc a1, %pcrel_hi(another_symbol)
45 # CHECK-NOPIC: addi a1, a1, %pcrel_lo(.Lpcrel_hi6)
50 # CHECK-NOPIC: addi a1, a1, %pcrel_lo(.Lpcrel_hi7)
4651 # CHECK-PIC: auipc a1, %got_pcrel_hi(another_symbol)
47 # CHECK-PIC-RV32: lw a1, %pcrel_lo(.Lpcrel_hi6)(a1)
48 # CHECK-PIC-RV64: ld a1, %pcrel_lo(.Lpcrel_hi6)(a1)
52 # CHECK-PIC-RV32: lw a1, %pcrel_lo(.Lpcrel_hi7)(a1)
53 # CHECK-PIC-RV64: ld a1, %pcrel_lo(.Lpcrel_hi7)(a1)
4954 la a1, another_symbol
5055
5156 # Check that we can load the address of symbols that are spelled like a register
52 # CHECK: .Lpcrel_hi7:
57 # CHECK: .Lpcrel_hi8:
5358 # CHECK-NOPIC: auipc a2, %pcrel_hi(zero)
54 # CHECK-NOPIC: addi a2, a2, %pcrel_lo(.Lpcrel_hi7)
59 # CHECK-NOPIC: addi a2, a2, %pcrel_lo(.Lpcrel_hi8)
5560 # CHECK-PIC: auipc a2, %got_pcrel_hi(zero)
56 # CHECK-PIC-RV32: lw a2, %pcrel_lo(.Lpcrel_hi7)(a2)
57 # CHECK-PIC-RV64: ld a2, %pcrel_lo(.Lpcrel_hi7)(a2)
61 # CHECK-PIC-RV32: lw a2, %pcrel_lo(.Lpcrel_hi8)(a2)
62 # CHECK-PIC-RV64: ld a2, %pcrel_lo(.Lpcrel_hi8)(a2)
5863 la a2, zero
5964
60 # CHECK: .Lpcrel_hi8:
65 # CHECK: .Lpcrel_hi9:
6166 # CHECK-NOPIC: auipc a3, %pcrel_hi(ra)
62 # CHECK-NOPIC: addi a3, a3, %pcrel_lo(.Lpcrel_hi8)
67 # CHECK-NOPIC: addi a3, a3, %pcrel_lo(.Lpcrel_hi9)
6368 # CHECK-PIC: auipc a3, %got_pcrel_hi(ra)
64 # CHECK-PIC-RV32: lw a3, %pcrel_lo(.Lpcrel_hi8)(a3)
65 # CHECK-PIC-RV64: ld a3, %pcrel_lo(.Lpcrel_hi8)(a3)
69 # CHECK-PIC-RV32: lw a3, %pcrel_lo(.Lpcrel_hi9)(a3)
70 # CHECK-PIC-RV64: ld a3, %pcrel_lo(.Lpcrel_hi9)(a3)
6671 la a3, ra
6772
68 # CHECK: .Lpcrel_hi9:
73 # CHECK: .Lpcrel_hi10:
6974 # CHECK-NOPIC: auipc a4, %pcrel_hi(f1)
70 # CHECK-NOPIC: addi a4, a4, %pcrel_lo(.Lpcrel_hi9)
75 # CHECK-NOPIC: addi a4, a4, %pcrel_lo(.Lpcrel_hi10)
7176 # CHECK-PIC: auipc a4, %got_pcrel_hi(f1)
72 # CHECK-PIC-RV32: lw a4, %pcrel_lo(.Lpcrel_hi9)(a4)
73 # CHECK-PIC-RV64: ld a4, %pcrel_lo(.Lpcrel_hi9)(a4)
77 # CHECK-PIC-RV32: lw a4, %pcrel_lo(.Lpcrel_hi10)(a4)
78 # CHECK-PIC-RV64: ld a4, %pcrel_lo(.Lpcrel_hi10)(a4)
7479 la a4, f1
7580
76 # CHECK: .Lpcrel_hi10:
81 # CHECK: .Lpcrel_hi11:
7782 # CHECK: auipc a0, %tls_ie_pcrel_hi(a_symbol)
78 # CHECK-RV32: lw a0, %pcrel_lo(.Lpcrel_hi10)(a0)
79 # CHECK-RV64: ld a0, %pcrel_lo(.Lpcrel_hi10)(a0)
83 # CHECK-RV32: lw a0, %pcrel_lo(.Lpcrel_hi11)(a0)
84 # CHECK-RV64: ld a0, %pcrel_lo(.Lpcrel_hi11)(a0)
8085 la.tls.ie a0, a_symbol
8186
82 # CHECK: .Lpcrel_hi11:
87 # CHECK: .Lpcrel_hi12:
8388 # CHECK: auipc a1, %tls_ie_pcrel_hi(another_symbol)
84 # CHECK-RV32: lw a1, %pcrel_lo(.Lpcrel_hi11)(a1)
85 # CHECK-RV64: ld a1, %pcrel_lo(.Lpcrel_hi11)(a1)
89 # CHECK-RV32: lw a1, %pcrel_lo(.Lpcrel_hi12)(a1)
90 # CHECK-RV64: ld a1, %pcrel_lo(.Lpcrel_hi12)(a1)
8691 la.tls.ie a1, another_symbol
8792
8893 # Check that we can load the address of symbols that are spelled like a register
89 # CHECK: .Lpcrel_hi12:
94 # CHECK: .Lpcrel_hi13:
9095 # CHECK: auipc a2, %tls_ie_pcrel_hi(zero)
91 # CHECK-RV32: lw a2, %pcrel_lo(.Lpcrel_hi12)(a2)
92 # CHECK-RV64: ld a2, %pcrel_lo(.Lpcrel_hi12)(a2)
96 # CHECK-RV32: lw a2, %pcrel_lo(.Lpcrel_hi13)(a2)
97 # CHECK-RV64: ld a2, %pcrel_lo(.Lpcrel_hi13)(a2)
9398 la.tls.ie a2, zero
9499
95 # CHECK: .Lpcrel_hi13:
100 # CHECK: .Lpcrel_hi14:
96101 # CHECK: auipc a3, %tls_ie_pcrel_hi(ra)
97 # CHECK-RV32: lw a3, %pcrel_lo(.Lpcrel_hi13)(a3)
98 # CHECK-RV64: ld a3, %pcrel_lo(.Lpcrel_hi13)(a3)
102 # CHECK-RV32: lw a3, %pcrel_lo(.Lpcrel_hi14)(a3)
103 # CHECK-RV64: ld a3, %pcrel_lo(.Lpcrel_hi14)(a3)
99104 la.tls.ie a3, ra
100105
101 # CHECK: .Lpcrel_hi14:
106 # CHECK: .Lpcrel_hi15:
102107 # CHECK: auipc a4, %tls_ie_pcrel_hi(f1)
103 # CHECK-RV32: lw a4, %pcrel_lo(.Lpcrel_hi14)(a4)
104 # CHECK-RV64: ld a4, %pcrel_lo(.Lpcrel_hi14)(a4)
108 # CHECK-RV32: lw a4, %pcrel_lo(.Lpcrel_hi15)(a4)
109 # CHECK-RV64: ld a4, %pcrel_lo(.Lpcrel_hi15)(a4)
105110 la.tls.ie a4, f1
106111
107 # CHECK: .Lpcrel_hi15:
112 # CHECK: .Lpcrel_hi16:
108113 # CHECK: auipc a0, %tls_gd_pcrel_hi(a_symbol)
109 # CHECK: addi a0, a0, %pcrel_lo(.Lpcrel_hi15)
114 # CHECK: addi a0, a0, %pcrel_lo(.Lpcrel_hi16)
110115 la.tls.gd a0, a_symbol
111116
112 # CHECK: .Lpcrel_hi16:
117 # CHECK: .Lpcrel_hi17:
113118 # CHECK: auipc a1, %tls_gd_pcrel_hi(another_symbol)
114 # CHECK: addi a1, a1, %pcrel_lo(.Lpcrel_hi16)
119 # CHECK: addi a1, a1, %pcrel_lo(.Lpcrel_hi17)
115120 la.tls.gd a1, another_symbol
116121
117122 # Check that we can load the address of symbols that are spelled like a register
118 # CHECK: .Lpcrel_hi17:
123 # CHECK: .Lpcrel_hi18:
119124 # CHECK: auipc a2, %tls_gd_pcrel_hi(zero)
120 # CHECK: addi a2, a2, %pcrel_lo(.Lpcrel_hi17)
125 # CHECK: addi a2, a2, %pcrel_lo(.Lpcrel_hi18)
121126 la.tls.gd a2, zero
122127
123 # CHECK: .Lpcrel_hi18:
128 # CHECK: .Lpcrel_hi19:
124129 # CHECK: auipc a3, %tls_gd_pcrel_hi(ra)
125 # CHECK: addi a3, a3, %pcrel_lo(.Lpcrel_hi18)
130 # CHECK: addi a3, a3, %pcrel_lo(.Lpcrel_hi19)
126131 la.tls.gd a3, ra
127132
128 # CHECK: .Lpcrel_hi19:
133 # CHECK: .Lpcrel_hi20:
129134 # CHECK: auipc a4, %tls_gd_pcrel_hi(f1)
130 # CHECK: addi a4, a4, %pcrel_lo(.Lpcrel_hi19)
135 # CHECK: addi a4, a4, %pcrel_lo(.Lpcrel_hi20)
131136 la.tls.gd a4, f1
132137
133 # CHECK: .Lpcrel_hi20:
138 # CHECK: .Lpcrel_hi21:
134139 # CHECK: auipc a0, %pcrel_hi(a_symbol)
135 # CHECK: lb a0, %pcrel_lo(.Lpcrel_hi20)(a0)
140 # CHECK: lb a0, %pcrel_lo(.Lpcrel_hi21)(a0)
136141 lb a0, a_symbol
137142
138 # CHECK: .Lpcrel_hi21:
143 # CHECK: .Lpcrel_hi22:
139144 # CHECK: auipc a1, %pcrel_hi(a_symbol)
140 # CHECK: lh a1, %pcrel_lo(.Lpcrel_hi21)(a1)
145 # CHECK: lh a1, %pcrel_lo(.Lpcrel_hi22)(a1)
141146 lh a1, a_symbol
142147
143 # CHECK: .Lpcrel_hi22:
148 # CHECK: .Lpcrel_hi23:
144149 # CHECK: auipc a2, %pcrel_hi(a_symbol)
145 # CHECK: lhu a2, %pcrel_lo(.Lpcrel_hi22)(a2)
150 # CHECK: lhu a2, %pcrel_lo(.Lpcrel_hi23)(a2)
146151 lhu a2, a_symbol
147152
148 # CHECK: .Lpcrel_hi23:
153 # CHECK: .Lpcrel_hi24:
149154 # CHECK: auipc a3, %pcrel_hi(a_symbol)
150 # CHECK: lw a3, %pcrel_lo(.Lpcrel_hi23)(a3)
155 # CHECK: lw a3, %pcrel_lo(.Lpcrel_hi24)(a3)
151156 lw a3, a_symbol
152
153 # CHECK: .Lpcrel_hi24:
154 # CHECK: auipc a4, %pcrel_hi(a_symbol)
155 # CHECK: sb a3, %pcrel_lo(.Lpcrel_hi24)(a4)
156 sb a3, a_symbol, a4
157157
158158 # CHECK: .Lpcrel_hi25:
159159 # CHECK: auipc a4, %pcrel_hi(a_symbol)
160 # CHECK: sh a3, %pcrel_lo(.Lpcrel_hi25)(a4)
161 sh a3, a_symbol, a4
160 # CHECK: sb a3, %pcrel_lo(.Lpcrel_hi25)(a4)
161 sb a3, a_symbol, a4
162162
163163 # CHECK: .Lpcrel_hi26:
164164 # CHECK: auipc a4, %pcrel_hi(a_symbol)
165 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi26)(a4)
165 # CHECK: sh a3, %pcrel_lo(.Lpcrel_hi26)(a4)
166 sh a3, a_symbol, a4
167
168 # CHECK: .Lpcrel_hi27:
169 # CHECK: auipc a4, %pcrel_hi(a_symbol)
170 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi27)(a4)
166171 sw a3, a_symbol, a4
167172
168173 # Check that we can load the address of symbols that are spelled like a register
169 # CHECK: .Lpcrel_hi27:
174 # CHECK: .Lpcrel_hi28:
170175 # CHECK: auipc a2, %pcrel_hi(zero)
171 # CHECK: lw a2, %pcrel_lo(.Lpcrel_hi27)(a2)
176 # CHECK: lw a2, %pcrel_lo(.Lpcrel_hi28)(a2)
172177 lw a2, zero
173178
174 # CHECK: .Lpcrel_hi28:
179 # CHECK: .Lpcrel_hi29:
175180 # CHECK: auipc a4, %pcrel_hi(zero)
176 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi28)(a4)
181 # CHECK: sw a3, %pcrel_lo(.Lpcrel_hi29)(a4)
177182 sw a3, zero, a4