1/*
2 * gomacro - A Go interpreter with Lisp-like macros
3 *
4 * Copyright (C) 2019 Massimiliano Ghilardi
5 *
6 *     This Source Code Form is subject to the terms of the Mozilla Public
7 *     License, v. 2.0. If a copy of the MPL was not distributed with this
8 *     file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 *
10 *
11 * alias.go
12 *
13 *  Created on Feb 13, 2019
14 *      Author Massimiliano Ghilardi
15 */
16
17package amd64
18
19import (
20	"reflect"
21
22	"github.com/cosmos72/gomacro/jit/common"
23)
24
25type (
26	Arch        = common.Arch
27	ArchId      = common.ArchId
28	Arg         = common.Arg
29	Asm         = common.Asm
30	AsmCode     = common.AsmCode // symbolic assembly code
31	Const       = common.Const
32	Kind        = common.Kind
33	MachineCode = common.MachineCode // assembled machine code
34	Mem         = common.Mem
35	Reg         = common.Reg
36	RegId       = common.RegId
37	RegIdConfig = common.RegIdConfig
38	RegIds      = common.RegIds
39	Save        = common.Save
40	SaveSlot    = common.SaveSlot
41	Size        = common.Size
42	SoftRegId   = common.SoftRegId
43	SoftRegIds  = common.SoftRegIds
44
45	Op0     = common.Op0
46	Op1     = common.Op1
47	Op2     = common.Op2
48	Op2Misc = common.Op2Misc
49	Op3     = common.Op3
50	Op4     = common.Op4
51)
52
53const (
54	MMAP_SUPPORTED = common.MMAP_SUPPORTED
55	SUPPORTED      = MMAP_SUPPORTED
56	NAME           = "amd64"
57
58	// ArchId
59	NOARCH = common.NOARCH
60	AMD64  = common.AMD64
61
62	// SaveSlot
63	InvalidSlot = common.InvalidSlot
64
65	// Kind
66	Invalid = common.Invalid
67	Bool    = common.Bool
68	Int     = common.Int
69	Int8    = common.Int8
70	Int16   = common.Int16
71	Int32   = common.Int32
72	Int64   = common.Int64
73	Uint    = common.Uint
74	Uint8   = common.Uint8
75	Uint16  = common.Uint16
76	Uint32  = common.Uint32
77	Uint64  = common.Uint64
78	Uintptr = common.Uintptr
79	Float32 = common.Float32
80	Float64 = common.Float64
81	Ptr     = common.Ptr
82	KLo     = common.KLo
83	KHi     = common.KHi
84
85	// RegId
86	NoRegId = common.NoRegId
87
88	// Op0
89	BAD = common.BAD
90	NOP = common.NOP
91	RET = common.RET
92
93	// Op1
94	ZERO = common.ZERO
95	INC  = common.INC
96	DEC  = common.DEC
97	NOT1 = common.NOT1
98	NEG1 = common.NEG1
99
100	// Op2
101	ADD2     = common.ADD2
102	SUB2     = common.SUB2
103	ADC2     = common.ADC2
104	SBB2     = common.SBB2
105	MUL2     = common.MUL2
106	DIV2     = common.DIV2
107	REM2     = common.REM2
108	AND2     = common.AND2
109	OR2      = common.OR2
110	XOR2     = common.XOR2
111	SHL2     = common.SHL2
112	SHR2     = common.SHR2
113	AND_NOT2 = common.AND_NOT2
114	LAND2    = common.LAND2
115	LOR2     = common.LOR2
116	MOV      = common.MOV
117	CAST     = common.CAST
118	LEA2     = common.LEA2
119	// CMP  = common.CMP
120	// XCHG = common.XCHG
121	NEG2 = common.NEG2
122	NOT2 = common.NOT2
123
124	// Op2Misc
125	ALLOC = common.ALLOC
126	FREE  = common.FREE
127	PUSH  = common.PUSH
128	POP   = common.POP
129
130	// Op3
131	ADD3     = common.ADD3
132	SUB3     = common.SUB3
133	ADC3     = common.ADC3
134	SBB3     = common.SBB3
135	MUL3     = common.MUL3
136	DIV3     = common.DIV3
137	REM3     = common.REM3
138	AND3     = common.AND3
139	OR3      = common.OR3
140	XOR3     = common.XOR3
141	SHL3     = common.SHL3
142	SHR3     = common.SHR3
143	AND_NOT3 = common.AND_NOT3
144	LAND3    = common.LAND3
145	LOR3     = common.LOR3
146	GETIDX   = common.GETIDX
147	SETIDX   = common.SETIDX
148
149	// Op4
150	LEA4 = common.LEA4
151)
152
153func ConstInt(val int) Const {
154	return common.ConstInt(val)
155}
156
157func ConstInt8(val int8) Const {
158	return common.ConstInt8(val)
159}
160
161func ConstInt16(val int16) Const {
162	return common.ConstInt16(val)
163}
164
165func ConstInt32(val int32) Const {
166	return common.ConstInt32(val)
167}
168
169func ConstInt64(val int64) Const {
170	return common.ConstInt64(val)
171}
172
173func ConstUint(val uint) Const {
174	return common.ConstUint(val)
175}
176
177func ConstUint8(val uint8) Const {
178	return common.ConstUint8(val)
179}
180
181func ConstUint16(val uint16) Const {
182	return common.ConstUint16(val)
183}
184
185func ConstUint32(val uint32) Const {
186	return common.ConstUint32(val)
187}
188
189func ConstUint64(val uint64) Const {
190	return common.ConstUint64(val)
191}
192
193func ConstUintptr(val uintptr) Const {
194	return common.ConstUintptr(val)
195}
196
197func ConstInterface(ival interface{}, t reflect.Type) (Const, error) {
198	return common.ConstInterface(ival, t)
199}
200
201func MakeConst(val int64, kind Kind) Const {
202	return common.MakeConst(val, kind)
203}
204
205func MakeMem(off int32, id RegId, kind Kind) Mem {
206	return common.MakeMem(off, id, kind)
207}
208
209func MakeReg(id RegId, kind Kind) Reg {
210	return common.MakeReg(id, kind)
211}
212
213func New() *Asm {
214	return common.NewArch(Amd64{})
215}
216
217func SizeOf(a Arg) Size {
218	return common.SizeOf(a)
219}
220
221func log2uint(n uint64) (uint8, bool) {
222	return common.Log2Uint(n)
223}
224