MCPcopy
hub / github.com/cilium/ebpf / String

Method String

asm/opcode.go:260–322  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258}
259
260func (op OpCode) String() string {
261 var f strings.Builder
262
263 switch class := op.Class(); {
264 case class.isLoadOrStore():
265 f.WriteString(strings.TrimSuffix(class.String(), "Class"))
266
267 mode := op.Mode()
268 f.WriteString(strings.TrimSuffix(mode.String(), "Mode"))
269
270 if atomic := op.AtomicOp(); atomic != InvalidAtomic {
271 f.WriteString(strings.TrimSuffix(atomic.String(), "Atomic"))
272 }
273
274 switch op.Size() {
275 case DWord:
276 f.WriteString("DW")
277 case Word:
278 f.WriteString("W")
279 case Half:
280 f.WriteString("H")
281 case Byte:
282 f.WriteString("B")
283 }
284
285 case class.IsALU():
286 if op.ALUOp() == Swap && op.Class() == ALU64Class {
287 // B to make BSwap, uncontitional byte swap
288 f.WriteString("B")
289 }
290
291 f.WriteString(op.ALUOp().String())
292
293 if op.ALUOp() == Swap {
294 if op.Class() == ALUClass {
295 // Width for Endian is controlled by Constant
296 f.WriteString(op.Endianness().String())
297 }
298 } else {
299 f.WriteString(strings.TrimSuffix(op.Source().String(), "Source"))
300
301 if class == ALUClass {
302 f.WriteString("32")
303 }
304 }
305
306 case class.IsJump():
307 f.WriteString(op.JumpOp().String())
308
309 if class == Jump32Class {
310 f.WriteString("32")
311 }
312
313 if jop := op.JumpOp(); jop != Exit && jop != Call && jop != Ja {
314 f.WriteString(strings.TrimSuffix(op.Source().String(), "Source"))
315 }
316
317 default:

Callers 1

TestReadSrcDstFunction · 0.45

Calls 12

ClassMethod · 0.95
ModeMethod · 0.95
AtomicOpMethod · 0.95
SizeMethod · 0.95
ALUOpMethod · 0.95
EndiannessMethod · 0.95
SourceMethod · 0.95
JumpOpMethod · 0.95
isLoadOrStoreMethod · 0.80
WriteStringMethod · 0.80
IsALUMethod · 0.80
IsJumpMethod · 0.80

Tested by 1

TestReadSrcDstFunction · 0.36