github.com/llir/llvm@v0.3.6/ir/constant/const_dso_local_equivalent.go (about) 1 package constant 2 3 import ( 4 "fmt" 5 6 "github.com/llir/llvm/ir/types" 7 ) 8 9 // --- [ dso_local_equivalent constants ] -------------------------------------- 10 11 // DSOLocalEquivalent is an LLVM IR dso_local_equivalent constant; a constant 12 // representing a function which is functionally equivalent to a given 13 // function, but is always defined in the current linkage unit. 14 // 15 // ref: https://llvm.org/docs/LangRef.html#dso-local-equivalent 16 type DSOLocalEquivalent struct { 17 // Underlying function. 18 Func Constant // *ir.Func 19 } 20 21 // NewDSOLocalEquivalent returns a new dso_local_equivalent constant based on 22 // the given function. 23 func NewDSOLocalEquivalent(f Constant) *DSOLocalEquivalent { 24 return &DSOLocalEquivalent{Func: f} 25 } 26 27 // String returns the LLVM syntax representation of the constant as a type-value 28 // pair. 29 func (c *DSOLocalEquivalent) String() string { 30 return fmt.Sprintf("%s %s", c.Type(), c.Ident()) 31 } 32 33 // Type returns the type of the constant. 34 func (c *DSOLocalEquivalent) Type() types.Type { 35 return c.Func.Type() 36 } 37 38 // Ident returns the identifier associated with the constant. 39 func (c *DSOLocalEquivalent) Ident() string { 40 // 'dso_local_equivalent' Func=GlobalIdent 41 return fmt.Sprintf("dso_local_equivalent %s", c.Func.Ident()) 42 }