-/*
- * Copyright (C) 2012, 2013, 2014
- * Wolfgang Bumiller
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
#ifndef GMQCC_IR_HDR
#define GMQCC_IR_HDR
#include "gmqcc.h"
*/
typedef uint8_t ir_flag_t;
-typedef struct ir_value_s ir_value;
-typedef struct ir_instr_s ir_instr;
-typedef struct ir_block_s ir_block;
-typedef struct ir_function_s ir_function;
-typedef struct ir_builder_s ir_builder;
+struct ir_value;
+struct ir_instr;
+struct ir_block;
+struct ir_function;
+struct ir_builder;
-typedef struct {
+struct ir_life_entry_t {
/* both inclusive */
size_t start;
size_t end;
-} ir_life_entry_t;
+};
enum {
IR_FLAG_HAS_ARRAYS = 1 << 0,
IR_FLAG_MASK_NO_LOCAL_TEMPS = (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
};
-struct ir_value_s {
+struct ir_value {
char *name;
int vtype;
int store;
void ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
/* PHI data */
-typedef struct ir_phi_entry_s {
+struct ir_phi_entry_t {
ir_value *value;
ir_block *from;
-} ir_phi_entry_t;
+};
/* instruction */
-struct ir_instr_s {
- int opcode;
- lex_ctx_t context;
- ir_value* (_ops[3]);
- ir_block* (bops[2]);
+struct ir_instr {
+ int opcode;
+ lex_ctx_t context;
+ ir_value *(_ops[3]);
+ ir_block *(bops[2]);
ir_phi_entry_t *phi;
- ir_value **params;
+ ir_value **params;
/* For the temp-allocation */
size_t eid;
/* For IFs */
- bool likely;
+ bool likely;
ir_block *owner;
};
/* block */
-struct ir_block_s {
+struct ir_block {
char *label;
lex_ctx_t context;
bool final; /* once a jump is added we're done */
bool GMQCC_WARN ir_block_create_goto(ir_block*, lex_ctx_t, ir_block *to);
/* function */
-struct ir_function_s {
+struct ir_function {
char *name;
int outtype;
int *params;
#define IR_HT_SIZE 1024
#define IR_MAX_VINSTR_TEMPS 1
-struct ir_builder_s {
+struct ir_builder {
char *name;
ir_function **functions;
ir_value **globals;