github.com/llir/llvm@v0.3.6/ir/value/value.go (about) 1 // Package value provides a definition of LLVM IR values. 2 package value 3 4 import ( 5 "fmt" 6 7 "github.com/llir/llvm/ir/types" 8 ) 9 10 // Value is an LLVM IR value, which may be used as an operand of instructions 11 // and terminators. 12 // 13 // A Value has one of the following underlying types. 14 // 15 // constant.Constant // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Constant 16 // value.Named // https://pkg.go.dev/github.com/llir/llvm/ir/value#Named 17 // TODO: add literal metadata value? 18 type Value interface { 19 // String returns the LLVM syntax representation of the value as a type-value 20 // pair. 21 fmt.Stringer 22 // Type returns the type of the value. 23 Type() types.Type 24 // Ident returns the identifier associated with the value. 25 Ident() string 26 } 27 28 // Named is a named LLVM IR value. 29 // 30 // A Named value has one of the following underlying types. 31 // 32 // *ir.Global // https://pkg.go.dev/github.com/llir/llvm/ir#Global 33 // *ir.Func // https://pkg.go.dev/github.com/llir/llvm/ir#Func 34 // *ir.Param // https://pkg.go.dev/github.com/llir/llvm/ir#Param 35 // *ir.Block // https://pkg.go.dev/github.com/llir/llvm/ir#Block 36 // TODO: add named metadata value? 37 // ir.Instruction // https://pkg.go.dev/github.com/llir/llvm/ir#Instruction (except store and fence) 38 // *ir.TermInvoke // https://pkg.go.dev/github.com/llir/llvm/ir#TermInvoke 39 // *ir.TermCatchSwitch // https://pkg.go.dev/github.com/llir/llvm/ir#TermCatchSwitch (token result used by catchpad) 40 type Named interface { 41 Value 42 // Name returns the name of the value. 43 Name() string 44 // SetName sets the name of the value. 45 SetName(name string) 46 } 47 48 // User is an instruction or terminator which uses values as operands. 49 type User interface { 50 // Operands returns a mutable list of operands of the given value user 51 // (instruction or terminator). 52 Operands() []*Value 53 }