Skip to content

Commit 99ed5e5

Browse files
committed
Apply feedback
1 parent a3dcd3d commit 99ed5e5

File tree

3 files changed

+61
-56
lines changed

3 files changed

+61
-56
lines changed

llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch,
329329

330330
static DecodeStatus DecodeCall(MCInst &MI, unsigned insn, uint64_t Address,
331331
const MCDisassembler *Decoder) {
332-
unsigned Offset = fieldFromInstruction(insn, 0, 30);
333-
int64_t CallTarget = Address + (SignExtend64(Offset, 30) * 4);
334-
if (!tryAddingSymbolicOperand(CallTarget, false, Address, 0, 30, MI, Decoder))
335-
MI.addOperand(MCOperand::createImm(CallTarget));
332+
int64_t CallOffset = SignExtend64(fieldFromInstruction(insn, 0, 30), 30) * 4;
333+
if (!tryAddingSymbolicOperand(Address + CallOffset, false, Address, 0, 30, MI,
334+
Decoder))
335+
MI.addOperand(MCOperand::createImm(CallOffset));
336336
return MCDisassembler::Success;
337337
}
338338

@@ -347,9 +347,9 @@ template <unsigned N>
347347
constexpr static DecodeStatus DecodeDisp(MCInst &MI, uint32_t ImmVal,
348348
uint64_t Address,
349349
const MCDisassembler *Decoder) {
350-
int64_t BranchTarget = Address + (SignExtend64(ImmVal, N) * 4);
351-
if (!tryAddingSymbolicOperand(BranchTarget, false, Address, 0, N, MI,
350+
int64_t BranchOffset = SignExtend64(ImmVal, N) * 4;
351+
if (!tryAddingSymbolicOperand(Address + BranchOffset, true, Address, 0, N, MI,
352352
Decoder))
353-
MI.addOperand(MCOperand::createImm(BranchTarget));
353+
MI.addOperand(MCOperand::createImm(BranchOffset));
354354
return MCDisassembler::Success;
355355
}

llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,16 @@ void SparcInstPrinter::printCTILabel(const MCInst *MI, uint64_t Address,
272272
// If the label has already been resolved to an immediate offset (say, when
273273
// we're running the disassembler), just print the immediate.
274274
if (Op.isImm()) {
275-
const int64_t Offset = Op.getImm();
276-
if (PrintBranchImmAsAddress)
277-
O << formatHex(Offset);
278-
else
275+
int64_t Offset = Op.getImm();
276+
if (PrintBranchImmAsAddress) {
277+
uint64_t Target = Address + Offset;
278+
O << formatHex(Target);
279+
} else {
280+
O << ".";
281+
if (Offset >= 0)
282+
O << "+";
279283
O << Offset;
284+
}
280285
return;
281286
}
282287

llvm/test/MC/Disassembler/Sparc/sparc.txt

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -81,142 +81,142 @@
8181
# CHECK: subxcc %g1, %g2, %g3
8282
0x86 0xe0 0x40 0x02
8383

84-
# CHECK: ba 104
84+
# CHECK: ba .-4
8585
0x10 0xbf 0xff 0xff
8686

87-
# CHECK: bne 108
87+
# CHECK: bne .-4
8888
0x12 0xbf 0xff 0xff
8989

90-
# CHECK: be 112
90+
# CHECK: be .-4
9191
0x02 0xbf 0xff 0xff
9292

93-
# CHECK: bg 116
93+
# CHECK: bg .-4
9494
0x14 0xbf 0xff 0xff
9595

96-
# CHECK: ble 120
96+
# CHECK: ble .-4
9797
0x04 0xbf 0xff 0xff
9898

99-
# CHECK: bge 124
99+
# CHECK: bge .-4
100100
0x16 0xbf 0xff 0xff
101101

102-
# CHECK: bl 128
102+
# CHECK: bl .-4
103103
0x06 0xbf 0xff 0xff
104104

105-
# CHECK: bgu 132
105+
# CHECK: bgu .-4
106106
0x18 0xbf 0xff 0xff
107107

108-
# CHECK: bleu 136
108+
# CHECK: bleu .-4
109109
0x08 0xbf 0xff 0xff
110110

111-
# CHECK: bcc 140
111+
# CHECK: bcc .-4
112112
0x1a 0xbf 0xff 0xff
113113

114-
# CHECK: bcs 144
114+
# CHECK: bcs .-4
115115
0x0a 0xbf 0xff 0xff
116116

117-
# CHECK: bpos 148
117+
# CHECK: bpos .-4
118118
0x1c 0xbf 0xff 0xff
119119

120-
# CHECK: bneg 152
120+
# CHECK: bneg .-4
121121
0x0c 0xbf 0xff 0xff
122122

123-
# CHECK: bvc 156
123+
# CHECK: bvc .-4
124124
0x1e 0xbf 0xff 0xff
125125

126-
# CHECK: bvs 160
126+
# CHECK: bvs .-4
127127
0x0e 0xbf 0xff 0xff
128128

129-
# CHECK: fbu 164
129+
# CHECK: fbu .-4
130130
0x0f 0xbf 0xff 0xff
131131

132-
# CHECK: fbg 168
132+
# CHECK: fbg .-4
133133
0x0d 0xbf 0xff 0xff
134134

135-
# CHECK: fbug 172
135+
# CHECK: fbug .-4
136136
0x0b 0xbf 0xff 0xff
137137

138-
# CHECK: fbl 176
138+
# CHECK: fbl .-4
139139
0x09 0xbf 0xff 0xff
140140

141-
# CHECK: fbul 180
141+
# CHECK: fbul .-4
142142
0x07 0xbf 0xff 0xff
143143

144-
# CHECK: fblg 184
144+
# CHECK: fblg .-4
145145
0x05 0xbf 0xff 0xff
146146

147-
# CHECK: fbne 188
147+
# CHECK: fbne .-4
148148
0x03 0xbf 0xff 0xff
149149

150-
# CHECK: fbe 192
150+
# CHECK: fbe .-4
151151
0x13 0xbf 0xff 0xff
152152

153-
# CHECK: fbue 196
153+
# CHECK: fbue .-4
154154
0x15 0xbf 0xff 0xff
155155

156-
# CHECK: fbge 200
156+
# CHECK: fbge .-4
157157
0x17 0xbf 0xff 0xff
158158

159-
# CHECK: fbuge 204
159+
# CHECK: fbuge .-4
160160
0x19 0xbf 0xff 0xff
161161

162-
# CHECK: fble 208
162+
# CHECK: fble .-4
163163
0x1b 0xbf 0xff 0xff
164164

165-
# CHECK: fbule 212
165+
# CHECK: fbule .-4
166166
0x1d 0xbf 0xff 0xff
167167

168-
# CHECK: fbo 216
168+
# CHECK: fbo .-4
169169
0x1f 0xbf 0xff 0xff
170170

171-
# CHECK: cba 220
171+
# CHECK: cba .-4
172172
0x11 0xff 0xff 0xff
173173

174-
# CHECK: cbn 224
174+
# CHECK: cbn .-4
175175
0x01 0xff 0xff 0xff
176176

177-
# CHECK: cb3 228
177+
# CHECK: cb3 .-4
178178
0x0f 0xff 0xff 0xff
179179

180-
# CHECK: cb2 232
180+
# CHECK: cb2 .-4
181181
0x0d 0xff 0xff 0xff
182182

183-
# CHECK: cb23 236
183+
# CHECK: cb23 .-4
184184
0x0b 0xff 0xff 0xff
185185

186-
# CHECK: cb1 240
186+
# CHECK: cb1 .-4
187187
0x09 0xff 0xff 0xff
188188

189-
# CHECK: cb13 244
189+
# CHECK: cb13 .-4
190190
0x07 0xff 0xff 0xff
191191

192-
# CHECK: cb12 248
192+
# CHECK: cb12 .-4
193193
0x05 0xff 0xff 0xff
194194

195-
# CHECK: cb123 252
195+
# CHECK: cb123 .-4
196196
0x03 0xff 0xff 0xff
197197

198-
# CHECK: cb03 256
198+
# CHECK: cb03 .-4
199199
0x15 0xff 0xff 0xff
200200

201-
# CHECK: cb02 260
201+
# CHECK: cb02 .-4
202202
0x17 0xff 0xff 0xff
203203

204-
# CHECK: cb023 264
204+
# CHECK: cb023 .-4
205205
0x19 0xff 0xff 0xff
206206

207-
# CHECK: cb01 268
207+
# CHECK: cb01 .-4
208208
0x1b 0xff 0xff 0xff
209209

210-
# CHECK: cb013 272
210+
# CHECK: cb013 .-4
211211
0x1d 0xff 0xff 0xff
212212

213-
# CHECK: cb012 276
213+
# CHECK: cb012 .-4
214214
0x1f 0xff 0xff 0xff
215215

216216
# CHECK: restore
217217
0x81 0xe8 0x00 0x00
218218

219-
# CHECK: call 304
219+
# CHECK: call .+16
220220
0x40 0x00 0x00 0x04
221221

222222
# CHECK: add %g1, -10, %g2

0 commit comments

Comments
 (0)