github.com/llir/llvm@v0.3.6/ir/metadata/sumtypes.go (about) 1 package metadata 2 3 import "fmt" 4 5 // TODO: constraint what types may be assigned to Node, MDNode, etc (i.e. make 6 // them sum types). 7 8 // Node is a metadata node. 9 // 10 // A Node has one of the following underlying types. 11 // 12 // metadata.Definition // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Definition 13 // *metadata.DIExpression // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIExpression 14 type Node interface { 15 // Ident returns the identifier associated with the metadata node. 16 Ident() string 17 } 18 19 // Definition is a metadata definition. 20 // 21 // A Definition has one of the following underlying types. 22 // 23 // metadata.MDNode // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#MDNode 24 type Definition interface { 25 // String returns the LLVM syntax representation of the metadata. 26 fmt.Stringer 27 // Ident returns the identifier associated with the metadata definition. 28 Ident() string 29 // ID returns the ID of the metadata definition. 30 ID() int64 31 // SetID sets the ID of the metadata definition. 32 SetID(id int64) 33 // LLString returns the LLVM syntax representation of the metadata 34 // definition. 35 LLString() string 36 // SetDistinct specifies whether the metadata definition is dinstict. 37 SetDistinct(distinct bool) 38 } 39 40 // MDNode is a metadata node. 41 // 42 // A MDNode has one of the following underlying types. 43 // 44 // *metadata.Tuple // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Tuple 45 // metadata.Definition // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Definition 46 // metadata.SpecializedNode // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#SpecializedNode 47 type MDNode interface { 48 // Ident returns the identifier associated with the metadata node. 49 Ident() string 50 // LLString returns the LLVM syntax representation of the metadata node. 51 LLString() string 52 } 53 54 // Field is a metadata field. 55 // 56 // A Field has one of the following underlying types. 57 // 58 // *metadata.NullLit // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#NullLit 59 // metadata.Metadata // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Metadata 60 type Field interface { 61 // String returns the LLVM syntax representation of the metadata field. 62 fmt.Stringer 63 } 64 65 // SpecializedNode is a specialized metadata node. 66 // 67 // A SpecializedNode has one of the following underlying types. 68 // 69 // *metadata.DIBasicType // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIBasicType 70 // *metadata.DICommonBlock // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DICommonBlock 71 // *metadata.DICompileUnit // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DICompileUnit 72 // *metadata.DICompositeType // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DICompositeType 73 // *metadata.DIDerivedType // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIDerivedType 74 // *metadata.DIEnumerator // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIEnumerator 75 // *metadata.DIExpression // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIExpression 76 // *metadata.DIFile // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIFile 77 // *metadata.DIGlobalVariable // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIGlobalVariable 78 // *metadata.DIGlobalVariableExpression // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIGlobalVariableExpression 79 // *metadata.DIImportedEntity // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIImportedEntity 80 // *metadata.DILabel // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DILabel 81 // *metadata.DILexicalBlock // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DILexicalBlock 82 // *metadata.DILexicalBlockFile // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DILexicalBlockFile 83 // *metadata.DILocalVariable // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DILocalVariable 84 // *metadata.DILocation // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DILocation 85 // *metadata.DIMacro // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIMacro 86 // *metadata.DIMacroFile // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIMacroFile 87 // *metadata.DIModule // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIModule 88 // *metadata.DINamespace // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DINamespace 89 // *metadata.DIObjCProperty // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIObjCProperty 90 // *metadata.DISubprogram // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DISubprogram 91 // *metadata.DISubrange // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DISubrange 92 // *metadata.DISubroutineType // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DISubroutineType 93 // *metadata.DITemplateTypeParameter // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DITemplateTypeParameter 94 // *metadata.DITemplateValueParameter // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DITemplateValueParameter 95 // *metadata.GenericDINode // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#GenericDINode 96 type SpecializedNode interface { 97 Definition 98 } 99 100 // FieldOrInt is a metadata field or integer. 101 // 102 // A FieldOrInt has one of the following underlying types. 103 // 104 // metadata.Field // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Field 105 // metadata.IntLit // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#IntLit 106 type FieldOrInt interface { 107 Field 108 } 109 110 // DIExpressionField is a metadata DIExpression field. 111 // 112 // A DIExpressionField has one of the following underlying types. 113 // 114 // metadata.UintLit // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#UintLit 115 // enum.DwarfAttEncoding // https://pkg.go.dev/github.com/llir/llvm/ir/enum#DwarfAttEncoding 116 // enum.DwarfOp // https://pkg.go.dev/github.com/llir/llvm/ir/enum#DwarfOp 117 type DIExpressionField interface { 118 fmt.Stringer 119 // IsDIExpressionField ensures that only DIExpression fields can be assigned 120 // to the metadata.DIExpressionField interface. 121 IsDIExpressionField() 122 } 123 124 // IsDIExpressionField ensures that only DIExpression fields can be assigned to 125 // the metadata.DIExpressionField interface. 126 func (UintLit) IsDIExpressionField() {} 127 128 // Metadata is a sumtype of metadata. 129 // 130 // A Metadata has one of the following underlying types. 131 // 132 // value.Value // https://pkg.go.dev/github.com/llir/llvm/ir/value#Value 133 // *metadata.String // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#String 134 // *metadata.Tuple // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Tuple 135 // metadata.Definition // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#Definition 136 // metadata.SpecializedNode // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#SpecializedNode 137 // *metadata.DIArgList // https://pkg.go.dev/github.com/llir/llvm/ir/metadata#DIArgList 138 type Metadata interface { 139 // String returns the LLVM syntax representation of the metadata. 140 fmt.Stringer 141 }