Skip to content

Commit

Permalink
asm,ir: add DwarfAttEncoding as valid DIExpressionField
Browse files Browse the repository at this point in the history
Updates #101, #105.
  • Loading branch information
mewmew committed Nov 28, 2019
1 parent fae9e10 commit 5a787c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions asm/specialized_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ func (gen *generator) irDIExpressionField(old ast.DIExpressionField) (metadata.D
switch old := old.(type) {
case *ast.UintLit:
return metadata.UintLit(uintLit(*old)), nil
case *ast.DwarfAttEncodingEnum:
return asmenum.DwarfAttEncodingFromString(old.Text()), nil
case *ast.DwarfOp:
return asmenum.DwarfOpFromString(old.Text()), nil
default:
Expand Down
4 changes: 4 additions & 0 deletions ir/enum/sumtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package enum

// === [ metadata.DIExpressionField ] ==========================================

// IsDIExpressionField ensures that only DIExpression fields can be assigned to
// the metadata.DIExpressionField interface.
func (DwarfAttEncoding) IsDIExpressionField() {}

// IsDIExpressionField ensures that only DIExpression fields can be assigned to
// the metadata.DIExpressionField interface.
func (DwarfOp) IsDIExpressionField() {}
Expand Down
5 changes: 3 additions & 2 deletions ir/metadata/sumtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ type FieldOrInt interface {
//
// A DIExpressionField has one of the following underlying types.
//
// metadata.UintLit // https://godoc.org/github.com/llir/llvm/ir/metadata#UintLit
// enum.DwarfOp // https://godoc.org/github.com/llir/llvm/ir/enum#DwarfOp
// metadata.UintLit // https://godoc.org/github.com/llir/llvm/ir/metadata#UintLit
// enum.DwarfAttEncoding // https://godoc.org/github.com/llir/llvm/ir/enum#DwarfAttEncoding
// enum.DwarfOp // https://godoc.org/github.com/llir/llvm/ir/enum#DwarfOp
type DIExpressionField interface {
fmt.Stringer
// IsDIExpressionField ensures that only DIExpression fields can be assigned
Expand Down

0 comments on commit 5a787c4

Please sign in to comment.