Commit 333d6983 authored by Matthias Braun's avatar Matthias Braun
Browse files

Merge x86_imm.h + x86_cc.h => x86_node.h

parent afd4e3d6
......@@ -13,7 +13,7 @@
#include <stdint.h>
#include "../ia32/x86_asm.h"
#include "../ia32/x86_cc.h"
#include "../ia32/x86_node.h"
#include "../ia32/x86_x87.h"
#include "../ia32/x86_address_mode.h"
#include "compiler.h"
......
......@@ -18,7 +18,7 @@
#include "irgwalk.h"
#include "irnode_t.h"
#include "panic.h"
#include "x86_imm.h"
#include "x86_node.h"
static bool is_externally_visible(ir_entity const *const entity)
{
......
......@@ -14,7 +14,7 @@
#include "firm_types.h"
#include "ia32_encode.h"
#include "jit.h"
#include "x86_cc.h"
#include "x86_node.h"
/**
* fmt parameter output
......
......@@ -25,7 +25,7 @@
#include "ia32_emitter.h"
#include "ia32_new_nodes.h"
#include "irnodehashmap.h"
#include "x86_cc.h"
#include "x86_node.h"
static ir_nodehashmap_t block_fragmentnum;
......
......@@ -14,7 +14,7 @@
#include "firm_types.h"
#include "irnode_t.h"
#include "x86_asm.h"
#include "x86_cc.h"
#include "x86_node.h"
#include "x86_x87.h"
#include "x86_address_mode.h"
......
......@@ -21,7 +21,7 @@
#include "ircons_t.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "x86_imm.h"
#include "x86_node.h"
/**
* Create a trampoline entity for the given method.
......
......@@ -13,7 +13,7 @@
#include "firm_types.h"
#include "x86_asm.h"
#include "x86_imm.h"
#include "x86_node.h"
extern const x86_clobber_name_t ia32_additional_clobber_names[];
extern const x86_asm_constraint_list_t ia32_asm_constraints;
......
......@@ -14,7 +14,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "x86_imm.h"
#include "x86_node.h"
typedef enum x86_addr_variant_t {
X86_ADDR_INVALID,
......
......@@ -18,7 +18,7 @@
#include "compiler.h"
#include "firm_types.h"
#include "util.h"
#include "x86_imm.h"
#include "x86_node.h"
typedef enum x86_asm_operand_kind_t {
ASM_OP_INVALID,
......
/*
* This file is part of libFirm.
* Copyright (C) 2015 University of Karlsruhe.
*/
/**
* @file
* @brief Data structures for immediate values and relocations.
* @author Matthias Braun
*/
#ifndef FIRM_BE_IA32_IMM_H
#define FIRM_BE_IA32_IMM_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "compiler.h"
#include "firm_types.h"
#include "irmode.h"
#include "panic.h"
extern char const *x86_pic_base_label;
/** instruction data size. Keep sorted! */
typedef enum x86_insn_size_t {
X86_SIZE_8,
X86_SIZE_16,
X86_SIZE_32,
X86_SIZE_64,
X86_SIZE_80,
X86_SIZE_128,
} x86_insn_size_t;
/** immediate/relocation types (see also ELF file format) */
typedef enum x86_immediate_kind_t {
X86_IMM_VALUE, /**< no relocation, just a value */
X86_IMM_ADDR, /**< "normal" absolute addresses to a symbol */
X86_IMM_PCREL, /**< PC relative address */
X86_IMM_PICBASE_REL, /**< relative to pic base address */
X86_IMM_TLS_IE, /**< thread local storage, initial exec */
X86_IMM_TLS_LE, /**< thread local storage, load exec */
X86_IMM_FRAMEENT, /**< offset to entity on stackframe */
/** The offset field specifies an offset relative to the SP value at
* the beginning of the function. The offset will be adjusted to the
* actualy stack pointer offset later. */
X86_IMM_FRAMEOFFSET,
X86_IMM_GOTPCREL, /**< global offset table entry PC relative (elf64) */
X86_IMM_GOTOFF, /**< address relative to global offset table */
X86_IMM_GOT, /**< global offset table entry offset */
X86_IMM_PLT, /**< address to entry in procedure linkage table */
} x86_immediate_kind_t;
typedef struct x86_imm32_t {
ir_entity *entity;
int32_t offset;
ENUMBF(x86_immediate_kind_t) kind:8;
} x86_imm32_t;
bool x86_match_immediate(x86_imm32_t *immediate, const ir_node *node,
char constraint);
char const *x86_get_immediate_kind_str(x86_immediate_kind_t const kind);
void x86_dump_imm32(x86_imm32_t const *imm, FILE *F);
void x86_emit_imm32(x86_imm32_t const *imm);
void x86_emit_relocation_no_offset(x86_immediate_kind_t kind,
ir_entity const *entity);
static inline bool x86_imm32_equal(x86_imm32_t const *const imm0,
x86_imm32_t const *const imm1)
{
return imm0->entity == imm1->entity && imm0->offset == imm1->offset
&& imm0->kind == imm1->kind;
}
static inline x86_insn_size_t x86_size_from_mode(ir_mode *const mode)
{
switch (get_mode_size_bits(mode)) {
case 8: return X86_SIZE_8;
case 16: return X86_SIZE_16;
case 32: return X86_SIZE_32;
case 64: return X86_SIZE_64;
case 80: return X86_SIZE_80;
case 128: return X86_SIZE_128;
}
panic("Unexpected mode");
}
static inline unsigned x86_bytes_from_size(x86_insn_size_t const size)
{
switch (size) {
case X86_SIZE_8: return 1;
case X86_SIZE_16: return 2;
case X86_SIZE_32: return 4;
case X86_SIZE_64: return 8;
case X86_SIZE_80: return 10;
case X86_SIZE_128: return 16;
}
panic("Invalid size");
}
#endif
#ifndef X86_CC_H
#define X86_CC_H
/*
* This file is part of libFirm.
* Copyright (C) 2016 University of Karlsruhe.
*/
/**
* @file
* @brief Data structures for immediate values and relocations.
* @author Matthias Braun
*/
#ifndef FIRM_BE_IA32_X86_NODES_ATTR_H
#define FIRM_BE_IA32_X86_NODES_ATTR_H
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include "irmode_t.h"
#include "panic.h"
/** x86 condition codes (the numbers correspond to the real encoding order) */
typedef enum x86_condition_code_t {
......@@ -55,6 +69,43 @@ typedef enum x86_condition_code_t {
} x86_condition_code_t;
ENUM_BITSET(x86_condition_code_t)
/** instruction data size. Keep sorted! */
typedef enum x86_insn_size_t {
X86_SIZE_8,
X86_SIZE_16,
X86_SIZE_32,
X86_SIZE_64,
X86_SIZE_80,
X86_SIZE_128,
} x86_insn_size_t;
/** immediate/relocation types (see also ELF file format) */
typedef enum x86_immediate_kind_t {
X86_IMM_VALUE, /**< no relocation, just a value */
X86_IMM_ADDR, /**< "normal" absolute addresses to a symbol */
X86_IMM_PCREL, /**< PC relative address */
X86_IMM_PICBASE_REL, /**< relative to pic base address */
X86_IMM_TLS_IE, /**< thread local storage, initial exec */
X86_IMM_TLS_LE, /**< thread local storage, load exec */
X86_IMM_FRAMEENT, /**< offset to entity on stackframe */
/** The offset field specifies an offset relative to the SP value at
* the beginning of the function. The offset will be adjusted to the
* actualy stack pointer offset later. */
X86_IMM_FRAMEOFFSET,
X86_IMM_GOTPCREL, /**< global offset table entry PC relative (elf64) */
X86_IMM_GOTOFF, /**< address relative to global offset table */
X86_IMM_GOT, /**< global offset table entry offset */
X86_IMM_PLT, /**< address to entry in procedure linkage table */
} x86_immediate_kind_t;
typedef struct x86_imm32_t {
ir_entity *entity;
int32_t offset;
ENUMBF(x86_immediate_kind_t) kind:8;
} x86_imm32_t;
extern char const *x86_pic_base_label;
static inline x86_condition_code_t x86_negate_condition_code(
x86_condition_code_t code)
{
......@@ -92,4 +143,48 @@ x86_condition_code_t ir_relation_to_x86_condition_code(ir_relation relation,
void x86_emit_condition_code(x86_condition_code_t cc);
bool x86_match_immediate(x86_imm32_t *immediate, const ir_node *node,
char constraint);
char const *x86_get_immediate_kind_str(x86_immediate_kind_t const kind);
void x86_dump_imm32(x86_imm32_t const *imm, FILE *F);
void x86_emit_imm32(x86_imm32_t const *imm);
void x86_emit_relocation_no_offset(x86_immediate_kind_t kind,
ir_entity const *entity);
static inline bool x86_imm32_equal(x86_imm32_t const *const imm0,
x86_imm32_t const *const imm1)
{
return imm0->entity == imm1->entity && imm0->offset == imm1->offset
&& imm0->kind == imm1->kind;
}
static inline x86_insn_size_t x86_size_from_mode(ir_mode *const mode)
{
switch (get_mode_size_bits(mode)) {
case 8: return X86_SIZE_8;
case 16: return X86_SIZE_16;
case 32: return X86_SIZE_32;
case 64: return X86_SIZE_64;
case 80: return X86_SIZE_80;
case 128: return X86_SIZE_128;
}
panic("Unexpected mode");
}
static inline unsigned x86_bytes_from_size(x86_insn_size_t const size)
{
switch (size) {
case X86_SIZE_8: return 1;
case X86_SIZE_16: return 2;
case X86_SIZE_32: return 4;
case X86_SIZE_64: return 8;
case X86_SIZE_80: return 10;
case X86_SIZE_128: return 16;
}
panic("Invalid size");
}
#endif
......@@ -8,7 +8,7 @@
* @brief Helper functions for immediates / relocations.
* @author Matthias Braun
*/
#include "x86_imm.h"
#include "x86_node.h"
#include <inttypes.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment