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

/**
 * @file
 * @brief       This file contains functions for matching firm graphs for
Michael Beck's avatar
Michael Beck committed
9
 *              nodes that can be used as address mode for x86 instructions
10
11
 * @author      Matthias Braun
 */
12
13
#ifndef X86_ADDRESS_MODE_H
#define X86_ADDRESS_MODE_H
14

15
#include <stdbool.h>
Matthias Braun's avatar
Matthias Braun committed
16
#include <stdint.h>
17
#include "irtypes.h"
18
#include "x86_imm.h"
19

Michael Beck's avatar
Michael Beck committed
20
21
22
/**
 * The address mode data: Used to construct (memory) address modes.
 */
23
typedef struct x86_address_t {
24
25
26
27
	ir_node    *base;            /**< value for base register (if any) */
	ir_node    *index;           /**< value for index register (if any). */
	ir_node    *mem;             /**< value for memory input (if any). */
	x86_imm32_t imm;
Matthias Braun's avatar
Matthias Braun committed
28
29
30
	unsigned   scale       : 8; /**< An integer scale. {0,1,2,3} */
	bool       use_frame   : 1; /**< Set, if the frame is accessed */
	bool       tls_segment : 1; /**< Set if AM is relative to TLS */
31
	bool       ip_base     : 1; /**< Base is instruction pointer (IP) */
32
} x86_address_t;
33

Michael Beck's avatar
Michael Beck committed
34
35
36
/**
 * Additional flags for the address mode creation.
 */
37
typedef enum x86_create_am_flags_t {
Matthias Braun's avatar
Matthias Braun committed
38
39
40
41
42
	x86_create_am_normal     = 0,
	/** Ignore non-address-mode markings on the root node. */
	x86_create_am_force      = 1U << 0,
	/** Fold AM, even if the root node has two users. */
	x86_create_am_double_use = 1U << 1,
43
} x86_create_am_flags_t;
44

Michael Beck's avatar
Michael Beck committed
45
46
47
/**
 * Create an address mode for a given node.
 */
48
49
void x86_create_address_mode(x86_address_t *addr, ir_node *node,
                             x86_create_am_flags_t);
50

Michael Beck's avatar
Michael Beck committed
51
52
53
54
/**
 * Mark those nodes of the given graph that cannot be used inside an
 * address mode because there values must be materialized in registers.
 */
55
void x86_calculate_non_address_mode_nodes(ir_graph *irg);
56

Michael Beck's avatar
Michael Beck committed
57
58
59
/**
 * Free the non_address_mode information.
 */
60
void x86_free_non_address_mode_nodes(void);
61

62
63
64
/**
 * Tells whether the given node is a non address mode node.
 */
65
bool x86_is_non_address_mode_node(ir_node const *node);
66

67
68
69
/**
 * mark a node so it will not be used as part of address modes
 */
70
void x86_mark_non_am(ir_node *node);
71

72
#endif