-
Notifications
You must be signed in to change notification settings - Fork 2
/
asm.go
66 lines (53 loc) · 787 Bytes
/
asm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package asm
import (
"github.com/rj45/nanogo/ir"
)
type Section string
const (
Code Section = "code"
Data Section = "data"
Bss Section = "bss"
)
type Program struct {
Pkg *ir.Package
Funcs []Func
}
type Func struct {
Comment string
Label string
Globals []*Global
Blocks []*Block
Func *ir.Func
}
type Global struct {
Section Section
Comment string
Label string
Strings []string
Value *ir.Value
}
type Op interface {
Asm() string
Fmt() Fmt
IsMove() bool
IsCall() bool
}
type Fmt interface {
Template() string
Vars(val *ir.Value) []*Var
}
type Instr struct {
Op Op
Args []*Var
Indent bool
}
type Block struct {
Label string
Instrs []*Instr
Block *ir.Block
}
type Var struct {
String string
Value *ir.Value
Block *ir.Block
}