blob: a371317625e4c1ac0d1aadfd29acc58bc3f88af8 [file] [log] [blame]
Jan Voungb36ad9b2015-04-21 17:01:49 -07001//===- subzero/src/IceInstARM32.def - X-Macros for ARM32 insts --*- C++ -*-===//
2//
3// The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines properties of ARM32 instructions in the form of x-macros.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef SUBZERO_SRC_ICEINSTARM32_DEF
15#define SUBZERO_SRC_ICEINSTARM32_DEF
16
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070017#include "IceRegList.h"
18
Jan Voungb36ad9b2015-04-21 17:01:49 -070019// NOTE: PC and SP are not considered isInt, to avoid register allocating.
Jan Voung0fa6c5a2015-06-01 11:04:04 -070020//
John Portoed2c06b2015-10-01 15:27:15 -070021// For the NaCl sandbox we also need to r9 (and the r8-r9 pair) for TLS, so
22// just reserve always.
23// TODO(jpp): Allow r9 to be isInt when sandboxing is turned off (native mode).
Jan Voung0fa6c5a2015-06-01 11:04:04 -070024//
Jan Voung28068ad2015-07-31 12:58:46 -070025// IP is not considered isInt to reserve it as a scratch register. A scratch
26// register is useful for expanding instructions post-register allocation.
27//
Andrew Scull57e12682015-09-16 11:30:19 -070028// LR is not considered isInt to avoid being allocated as a register. It is
29// technically preserved, but save/restore is handled separately, based on
30// whether or not the function MaybeLeafFunc.
John Portoeb13acc2015-12-09 05:10:58 -080031//
32// The register tables can be generated using the gen_arm32_reg_tables.py
33// script.
John Porto5300bfe2015-09-08 09:03:22 -070034
John Porto2187c842015-12-16 07:48:25 -080035#include "IceRegistersARM32.def"
36// The register tables defined in IceRegistersARM32 use the following x-macro:
37//#define X(val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr,
John Portodff7dbd2016-01-04 09:49:55 -080038// isGPR, isInt, isI64Pair, isFP32, isFP64, isVec128, alias_init)
Jan Voungb36ad9b2015-04-21 17:01:49 -070039
Andrew Scull57e12682015-09-16 11:30:19 -070040// We also provide a combined table, so that there is a namespace where all of
41// the registers are considered and have distinct numberings. This is in
42// contrast to the above, where the "encode" is based on how the register
43// numbers will be encoded in binaries and values can overlap.
Jan Voung86ebec12015-08-09 07:58:35 -070044#define REGARM32_TABLE \
John Porto2187c842015-12-16 07:48:25 -080045 /* val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr, \
John Portodff7dbd2016-01-04 09:49:55 -080046 isGPR, isInt, isI64Pair, isFP32, isFP64, isVec128, alias_init */ \
Jan Voung86ebec12015-08-09 07:58:35 -070047 REGARM32_GPR_TABLE \
John Portoed2c06b2015-10-01 15:27:15 -070048 REGARM32_I64PAIR_TABLE \
Jan Voung86ebec12015-08-09 07:58:35 -070049 REGARM32_FP32_TABLE \
50 REGARM32_FP64_TABLE \
51 REGARM32_VEC128_TABLE
John Porto2187c842015-12-16 07:48:25 -080052//#define X(val, encode, name, cc_arg, scratch, preserved, stackptr, frameptr,
John Portodff7dbd2016-01-04 09:49:55 -080053// isGPR, isInt, isFP32, isFP64, isVec128, alias_init)
Jan Voungb36ad9b2015-04-21 17:01:49 -070054
Jan Voung86ebec12015-08-09 07:58:35 -070055#define REGARM32_TABLE_BOUNDS \
56 /* val, init */ \
57 X(Reg_GPR_First, = Reg_r0) \
58 X(Reg_GPR_Last, = Reg_pc) \
John Portoed2c06b2015-10-01 15:27:15 -070059 X(Reg_I64PAIR_First, = Reg_r0r1) \
60 X(Reg_I64PAIR_Last, = Reg_r10fp) \
Jan Voung86ebec12015-08-09 07:58:35 -070061 X(Reg_SREG_First, = Reg_s0) \
62 X(Reg_SREG_Last, = Reg_s31) \
63 X(Reg_DREG_First, = Reg_d0) \
64 X(Reg_DREG_Last, = Reg_d31) \
65 X(Reg_QREG_First, = Reg_q0) \
66 X(Reg_QREG_Last, = Reg_q15)
67// define X(val, init)
Jan Voungb36ad9b2015-04-21 17:01:49 -070068
Jan Voung86ebec12015-08-09 07:58:35 -070069// Load/Store instruction width suffixes and FP/Vector element size suffixes
Andrew Scull57e12682015-09-16 11:30:19 -070070// the # of offset bits allowed as part of an addressing mode (for sign or zero
71// extending load/stores).
Jan Voung86ebec12015-08-09 07:58:35 -070072#define ICETYPEARM32_TABLE \
John Porto15e77d42016-04-13 12:57:14 -070073 /* tag, element type, int_width, fp_width, uvec_width, svec_width, \
74 addr bits sext, zext, reg-reg addr allowed, shift allowed, */ \
75 X(IceType_void, IceType_void, "" , "" , "" , "" , 0 , 0 , 0, 0) \
76 X(IceType_i1, IceType_void, "b", "" , "" , "" , 8 , 12, 1, 1) \
77 X(IceType_i8, IceType_void, "b", "" , "" , "" , 8 , 12, 1, 1) \
78 X(IceType_i16, IceType_void, "h", "" , "" , "" , 8 , 8 , 1, 0) \
79 X(IceType_i32, IceType_void, "" , "" , "" , "" , 12, 12, 1, 1) \
80 X(IceType_i64, IceType_void, "d", "" , "" , "" , 12, 12, 1, 1) \
81 X(IceType_f32, IceType_void, "" , ".f32", "" , "" , 8, 8 , 0, 0) \
82 X(IceType_f64, IceType_void, "" , ".f64", "" , "" , 8, 8 , 0, 0) \
83 X(IceType_v4i1, IceType_i32 , "" , ".i32", ".u32", ".s32", 0 , 0 , 1, 0) \
84 X(IceType_v8i1, IceType_i16 , "" , ".i16", ".u16", ".s16", 0 , 0 , 1, 0) \
85 X(IceType_v16i1, IceType_i8 , "" , ".i8" , ".u8" , ".s8" , 0 , 0 , 1, 0) \
86 X(IceType_v16i8, IceType_i8 , "" , ".i8" , ".u8" , ".s8" , 0 , 0 , 1, 0) \
87 X(IceType_v8i16, IceType_i16 , "" , ".i16", ".u16", ".s16", 0 , 0 , 1, 0) \
88 X(IceType_v4i32, IceType_i32 , "" , ".i32", ".u32", ".s32", 0 , 0 , 1, 0) \
89 X(IceType_v4f32, IceType_f32 , "" , ".f32", ".f32", ".f32", 0 , 0 , 1, 0)
90//#define X(tag, elementty, int_width, fp_width, uvec_width, svec_width, sbits,
91// ubits, rraddr, shaddr)
Jan Voungb36ad9b2015-04-21 17:01:49 -070092
Jan Voungb3401d22015-05-18 09:38:21 -070093// Shifter types for Data-processing operands as defined in section A5.1.2.
Jan Voung86ebec12015-08-09 07:58:35 -070094#define ICEINSTARM32SHIFT_TABLE \
95 /* enum value, emit */ \
96 X(LSL, "lsl") \
97 X(LSR, "lsr") \
98 X(ASR, "asr") \
99 X(ROR, "ror") \
100 X(RRX, "rrx")
Jan Voungb3401d22015-05-18 09:38:21 -0700101//#define X(tag, emit)
102
Andrew Scull57e12682015-09-16 11:30:19 -0700103// Attributes for the condition code 4-bit encoding (that is independent of the
104// APSR's NZCV fields). For example, EQ is 0, but corresponds to Z = 1, and NE
105// is 1, but corresponds to Z = 0.
Jan Voung86ebec12015-08-09 07:58:35 -0700106#define ICEINSTARM32COND_TABLE \
107 /* enum value, encoding, opposite, emit */ \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700108 X(EQ, 0, NE, "eq") /* equal */ \
109 X(NE, 1, EQ, "ne") /* not equal */ \
110 X(CS, 2, CC, "cs") /* carry set/unsigned (AKA hs: higher or same) */ \
111 X(CC, 3, CS, "cc") /* carry clear/unsigned (AKA lo: lower) */ \
112 X(MI, 4, PL, "mi") /* minus/negative */ \
113 X(PL, 5, MI, "pl") /* plus/positive or zero */ \
114 X(VS, 6, VC, "vs") /* overflow (float unordered) */ \
115 X(VC, 7, VS, "vc") /* no overflow (float not unordered) */ \
116 X(HI, 8, LS, "hi") /* unsigned higher */ \
117 X(LS, 9, HI, "ls") /* unsigned lower or same */ \
118 X(GE, 10, LT, "ge") /* signed greater than or equal */ \
119 X(LT, 11, GE, "lt") /* signed less than */ \
120 X(GT, 12, LE, "gt") /* signed greater than */ \
121 X(LE, 13, GT, "le") /* signed less than or equal */ \
122 X(AL, 14, kNone, "") /* always (unconditional) */ \
Jan Voung86ebec12015-08-09 07:58:35 -0700123 X(kNone, 15, kNone, "??") /* special condition / none */
John Portoed2c06b2015-10-01 15:27:15 -0700124//#define X(tag, encode, opp, emit)
Jan Voung3bfd99a2015-05-22 16:35:25 -0700125
Jan Voungb36ad9b2015-04-21 17:01:49 -0700126#endif // SUBZERO_SRC_ICEINSTARM32_DEF