amd64_nodes_attr.h 2.46 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 "compiler.h"
16
#include "irtypes.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
	AMD64_OP_NONE,
	AMD64_OP_ADDR,
	AMD64_OP_REG,
47
	AMD64_OP_REG_ADDR,
Matthias Braun's avatar
Matthias Braun committed
48
49
50
51
52
53
	AMD64_OP_REG_REG,
	AMD64_OP_REG_IMM,
	AMD64_OP_IMM32,
	AMD64_OP_IMM64,
	AMD64_OP_ADDR_REG,
	AMD64_OP_ADDR_IMM,
54
	AMD64_OP_UNOP_IMM32,
Matthias Braun's avatar
Matthias Braun committed
55
56
	AMD64_OP_SHIFT_REG,
	AMD64_OP_SHIFT_IMM,
Matthias Braun's avatar
Matthias Braun committed
57
58
} amd64_op_mode_t;

Matthias Braun's avatar
Matthias Braun committed
59
60
61
62
63
enum {
	NO_INPUT  = 0xFF,
	RIP_INPUT = 0xFE, /* can be used as base_input for PIC code */
};

Matthias Braun's avatar
Matthias Braun committed
64
typedef struct {
Matthias Braun's avatar
Matthias Braun committed
65
66
67
	ir_entity                   *entity;
	int64_t                      offset;
	ENUMBF(x86_immediate_kind_t) kind : 8;
Matthias Braun's avatar
Matthias Braun committed
68
69
70
} amd64_imm64_t;

typedef struct {
Matthias Braun's avatar
Matthias Braun committed
71
72
73
74
75
	x86_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
76
	ENUMBF(amd64_segment_selector_t) segment : 4;
Matthias Braun's avatar
Matthias Braun committed
77
78
79
80
} amd64_addr_t;

typedef struct {
	except_attr exc; /**< the exception attribute. MUST be the first one. */
81
	amd64_op_mode_t op_mode;
Matthias Braun's avatar
Matthias Braun committed
82
} amd64_attr_t;
83

Matthias Braun's avatar
Matthias Braun committed
84
85
86
typedef struct {
	amd64_attr_t base;
	bool                      needs_frame_ent : 1;
87
	ENUMBF(amd64_insn_mode_t) insn_mode       : 3;
Matthias Braun's avatar
Matthias Braun committed
88
89
90
91
92
93
	amd64_addr_t addr;
} amd64_addr_attr_t;

typedef struct {
	amd64_addr_attr_t base;
	union {
Matthias Braun's avatar
Matthias Braun committed
94
95
		uint8_t     reg_input;
		x86_imm32_t immediate;
Matthias Braun's avatar
Matthias Braun committed
96
97
98
99
100
	} u;
} amd64_binop_addr_attr_t;

typedef struct {
	amd64_attr_t base;
101
	ENUMBF(amd64_insn_mode_t) insn_mode : 3;
Matthias Braun's avatar
Matthias Braun committed
102
103
	uint8_t                   immediate;
} amd64_shift_attr_t;
104

Matthias Braun's avatar
Matthias Braun committed
105
106
typedef struct {
	amd64_attr_t base;
107
	ENUMBF(amd64_insn_mode_t) insn_mode : 3;
Matthias Braun's avatar
Matthias Braun committed
108
109
110
111
	amd64_imm64_t             immediate;
} amd64_movimm_attr_t;

typedef struct {
112
113
	amd64_attr_t         base;
	x86_condition_code_t cc;
Matthias Braun's avatar
Matthias Braun committed
114
} amd64_cc_attr_t;
115

Matthias Braun's avatar
Matthias Braun committed
116
typedef struct {
117
118
119
	amd64_attr_t           base;
	const ir_switch_table *table;
	ir_entity             *table_entity;
Matthias Braun's avatar
Matthias Braun committed
120
} amd64_switch_jmp_attr_t;
121

122
#endif