github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/insn.go (about) 1 package ccall 2 3 /* 4 #cgo CFLAGS: -I../ 5 #cgo CFLAGS: -Iinclude 6 7 #include <jit/jit.h> 8 */ 9 import "C" 10 import "unsafe" 11 12 type Instruction struct { 13 c C.jit_insn_t 14 } 15 16 func toInstruction(c C.jit_insn_t) *Instruction { 17 return &Instruction{c} 18 } 19 20 func (i *Instruction) Code() int { 21 return int(C.jit_insn_get_opcode(i.c)) 22 } 23 24 func (i *Instruction) Dest() *Value { 25 return toValue(C.jit_insn_get_dest(i.c)) 26 } 27 28 func (i *Instruction) Value1() *Value { 29 return toValue(C.jit_insn_get_value1(i.c)) 30 } 31 32 func (i *Instruction) Value2() *Value { 33 return toValue(C.jit_insn_get_value2(i.c)) 34 } 35 36 func (i *Instruction) Label() *Label { 37 return toLabel(C.jit_insn_get_label(i.c)) 38 } 39 40 func (i *Instruction) Function() *Function { 41 return toFunction(C.jit_insn_get_function(i.c)) 42 } 43 44 func (i *Instruction) Native() unsafe.Pointer { 45 return C.jit_insn_get_native(i.c) 46 } 47 48 func (i *Instruction) Name() string { 49 return C.GoString(C.jit_insn_get_name(i.c)) 50 } 51 52 func (i *Instruction) Signature() *Type { 53 return toType(C.jit_insn_get_signature(i.c)) 54 } 55 56 func (i *Instruction) DestIsValue() bool { 57 return int(C.jit_insn_dest_is_value(i.c)) == 1 58 }