amd64_nodes_attr.h 2.66 KB
Newer Older
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
4
5
6
7
8
9
 */

/**
 * @file
 * @brief   attributes attached to all amd64 nodes
 */
10
11
#ifndef FIRM_BE_AMD64_AMD64_NODES_ATTR_H
#define FIRM_BE_AMD64_AMD64_NODES_ATTR_H
12

13
#include <stdint.h>
Matthias Braun's avatar
Matthias Braun committed
14

15
#include "bearch.h"
Matthias Braun's avatar
Matthias Braun committed
16
#include "compiler.h"
17
#include "../ia32/x86_cc.h"
18
#include "../ia32/x86_asm.h"
19

20
21
22
23
enum amd64_arch_irn_flags_t {
	amd64_arch_irn_flag_commutative_binop = arch_irn_flag_backend << 0,
};

24
typedef enum {
25
	INSN_MODE_INVALID = 0,
26
	INSN_MODE_128,
27
28
29
30
31
32
	INSN_MODE_64,
	INSN_MODE_32,
	INSN_MODE_16,
	INSN_MODE_8
} amd64_insn_mode_t;

Matthias Braun's avatar
Matthias Braun committed
33
34
35
36
37
38
39
40
41
42
typedef enum {
	AMD64_SEGMENT_DEFAULT,
	AMD64_SEGMENT_CS,
	AMD64_SEGMENT_SS,
	AMD64_SEGMENT_DS,
	AMD64_SEGMENT_ES,
	AMD64_SEGMENT_FS,
	AMD64_SEGMENT_GS,
} amd64_segment_selector_t;

Matthias Braun's avatar
Matthias Braun committed
43
typedef enum {
Matthias Braun's avatar
Matthias Braun committed
44
45
46
47
48
49
50
51
52
53
	AMD64_OP_NONE,
	AMD64_OP_ADDR,
	AMD64_OP_REG,
	AMD64_OP_REG_REG,
	AMD64_OP_REG_IMM,
	AMD64_OP_IMM32,
	AMD64_OP_IMM64,
	AMD64_OP_ADDR_REG,
	AMD64_OP_ADDR_IMM,
	AMD64_OP_UNOP_REG,
54
55
	AMD64_OP_UNOP_IMM32,
	AMD64_OP_UNOP_ADDR,
Matthias Braun's avatar
Matthias Braun committed
56
57
	AMD64_OP_SHIFT_REG,
	AMD64_OP_SHIFT_IMM,
58
59
60
61
	/** A binary operation with 1 operand being RAX (which is usually not
	 * explicitely given in the assembly */
	AMD64_OP_RAX_REG,
	AMD64_OP_RAX_ADDR,
Matthias Braun's avatar
Matthias Braun committed
62
63
} amd64_op_mode_t;

Matthias Braun's avatar
Matthias Braun committed
64
65
66
67
68
enum {
	NO_INPUT  = 0xFF,
	RIP_INPUT = 0xFE, /* can be used as base_input for PIC code */
};

Matthias Braun's avatar
Matthias Braun committed
69
70
typedef struct {
	ir_entity *entity;
Matthias Braun's avatar
Matthias Braun committed
71
	int32_t    offset;
Matthias Braun's avatar
Matthias Braun committed
72
73
74
} amd64_imm32_t;

typedef struct {
75
	ir_entity *entity;
Matthias Braun's avatar
Matthias Braun committed
76
77
78
79
80
81
82
83
84
	int64_t    offset;
} amd64_imm64_t;

typedef struct {
	amd64_imm32_t immediate;
	uint8_t       base_input;
	uint8_t       index_input;
	uint8_t       mem_input;
	unsigned      log_scale : 2; /* 0, 1, 2, 3  (giving scale 1, 2, 4, 8) */
Matthias Braun's avatar
Matthias Braun committed
85
	ENUMBF(amd64_segment_selector_t) segment : 4;
Matthias Braun's avatar
Matthias Braun committed
86
87
88
89
90
91
} amd64_addr_t;

typedef struct {
	except_attr exc; /**< the exception attribute. MUST be the first one. */
	ENUMBF(amd64_op_mode_t) op_mode : 4;
} amd64_attr_t;
92

Matthias Braun's avatar
Matthias Braun committed
93
94
95
typedef struct {
	amd64_attr_t base;
	bool                      needs_frame_ent : 1;
96
	ENUMBF(amd64_insn_mode_t) insn_mode       : 3;
Matthias Braun's avatar
Matthias Braun committed
97
98
99
100
101
102
103
104
105
106
107
108
109
	amd64_addr_t addr;
} amd64_addr_attr_t;

typedef struct {
	amd64_addr_attr_t base;
	union {
		uint8_t       reg_input;
		amd64_imm32_t immediate;
	} u;
} amd64_binop_addr_attr_t;

typedef struct {
	amd64_attr_t base;
110
	ENUMBF(amd64_insn_mode_t) insn_mode : 3;
Matthias Braun's avatar
Matthias Braun committed
111
112
	uint8_t                   immediate;
} amd64_shift_attr_t;
113

Matthias Braun's avatar
Matthias Braun committed
114
115
typedef struct {
	amd64_attr_t base;
116
	ENUMBF(amd64_insn_mode_t) insn_mode : 3;
Matthias Braun's avatar
Matthias Braun committed
117
118
119
120
	amd64_imm64_t             immediate;
} amd64_movimm_attr_t;

typedef struct {
121
122
	amd64_attr_t         base;
	x86_condition_code_t cc;
Matthias Braun's avatar
Matthias Braun committed
123
} amd64_cc_attr_t;
124

Matthias Braun's avatar
Matthias Braun committed
125
typedef struct {
126
127
128
	amd64_attr_t           base;
	const ir_switch_table *table;
	ir_entity             *table_entity;
Matthias Braun's avatar
Matthias Braun committed
129
} amd64_switch_jmp_attr_t;
130

131
#endif