1%% -*- erlang-indent-level: 2 -*-
2%%
3%% Licensed under the Apache License, Version 2.0 (the "License");
4%% you may not use this file except in compliance with the License.
5%% You may obtain a copy of the License at
6%%
7%%     http://www.apache.org/licenses/LICENSE-2.0
8%%
9%% Unless required by applicable law or agreed to in writing, software
10%% distributed under the License is distributed on an "AS IS" BASIS,
11%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12%% See the License for the specific language governing permissions and
13%% limitations under the License.
14
15%%%--------------------------------------------------------------------
16%%% Basic Values:
17%%%
18%%% temp	::= #arm_temp{reg, type, allocatable}
19%%% reg		::= <token from hipe_arm_registers>
20%%% type	::= tagged | untagged
21%%% allocatable	::= true | false
22%%%
23%%% sdesc	::= #arm_sdesc{exnlab, fsize, arity, live}
24%%% exnlab	::= [] | label
25%%% fsize	::= int32		(frame size in words)
26%%% live	::= <tuple of int32>	(word offsets)
27%%% arity	::= uint8
28%%%
29%%% mfa		::= #arm_mfa{atom, atom, arity}
30%%% prim	::= #arm_prim{atom}
31
32-record(arm_mfa, {m::atom(), f::atom(), a::arity()}).
33-record(arm_prim, {prim}).
34-record(arm_sdesc, {exnlab, fsize, arity::arity(), live}).
35-record(arm_temp, {reg, type, allocatable}).
36
37%%% Instruction Operands:
38%%%
39%%% aluop	::= adc | add | and | bic | eor | orr | rsb | rsc | sbc | sub
40%%% cmpop	::= cmn | cmp | tst | teq	(alu with s flag and no dst)
41%%% cond	::= eq | ne | hs | lo | mi | pl | vs | vc | hi | ls | ge | lt | gt | le | al
42%%% ldop	::= ldr | ldrb			(am2)
43%%% movop	::= mov | mvn			(alu with no src)
44%%% stop	::= str | strb			(am2)
45%%%
46%%% dst		::= temp
47%%% src		::= temp
48%%%
49%%% s		::= true | false
50%%%
51%%% imm<N>	::= <an N-bit non-negative integer>
52%%%
53%%% Note: am1 represents all 11 variants of "Adressing Mode 1".
54%%%
55%%% am1		::= {imm8,imm4}		imm8 rotated right 2*imm4 bits
56%%%		  | src
57%%%		  | {src,rrx}
58%%%		  | {src,shiftop,imm5}
59%%%		  | {src,shiftop,src}
60%%% shiftop	::= lsl | lsr | asr | ror
61%%%
62%%% Note: am2 can represent the first 3 variants of "Addressing Mode 2",
63%%% i.e., not the pre- or post-indexed variants.
64%%%
65%%% am2		::= #am2{src, sign, am2offset}
66%%% am2offset	::= imm12 | src | {src,rrx} | {src,shiftop,imm5}
67%%% sign	::= + | -
68%%%
69%%% Note: am3 can represent the first 2 variants of "Addressing Mode 3",
70%%% i.e., not the pre- or post-indexed variants.
71%%%
72%%% am3		::= #am3{src, sign, am3offset}
73%%% am3offset	::= imm8 | src
74%%%
75%%% fun		::= mfa | prim
76%%% funv	::= mfa | prim | temp
77%%%
78%%% immediate	::= int32 | atom | {label,label_type}
79%%% label_type	::= constant | closure | c_const
80
81-record(am2, {src, sign, offset}).
82-record(am3, {src, sign, offset}).
83
84%%% Instructions:
85
86-record(alu, {aluop, s, dst, src, am1}).% cond not included
87-record(b_fun, {'fun', linkage}).	% known tailcall; cond not included
88-record(b_label, {'cond', label}).	% local jump
89-record(bl, {'fun', sdesc, linkage}).	% known recursive call; cond not included
90-record(blx, {src, sdesc}).		% computed recursive call; cond not included
91-record(cmp, {cmpop, src, am1}).	% cond not included
92-record(comment, {term}).
93-record(label, {label}).
94-record(load, {ldop, dst, am2}).	% cond not included; ldrh/ldrsh not included
95-record(ldrsb, {dst, am3}).		% cond not included
96-record(move, {movop, s, dst, am1}).	% cond not included
97-record(pseudo_bc, {'cond', true_label, false_label, pred}).
98-record(pseudo_blr, {}).		% alias for "mov pc,lr" to help cfg
99-record(pseudo_bx, {src}).		% alias for "mov pc,src" to help cfg
100-record(pseudo_call, {funv, sdesc, contlab, linkage}).
101-record(pseudo_call_prepare, {nrstkargs}).
102-record(pseudo_li, {dst, imm, label}).	% pre-generated label for use by the assembler
103-record(pseudo_move, {dst, src}).
104-record(pseudo_spill_move, {dst, temp, src}).
105-record(pseudo_switch, {jtab, index, labels}).
106-record(pseudo_tailcall, {funv, arity, stkargs, linkage}).
107-record(pseudo_tailcall_prepare, {}).
108-record(smull, {dstlo, dsthi, src1, src2}). % cond not included, s not included
109-record(store, {stop, src, am2}).	% cond not included; strh not included
110
111%%% Function definitions.
112
113-include("../misc/hipe_consttab.hrl").
114
115-record(defun, {mfa :: mfa(), formals, code,
116	       	data	  :: hipe_consttab(),
117	        isclosure :: boolean(),
118		isleaf    :: boolean(),
119		var_range, label_range}).
120