# HG changeset patch # User Shinji KONO # Date 1351832675 -32400 # Node ID 5b631c16f89bc54a918d4f7d5e229fdc046130fa # Parent 8741552a4e4b3f529c5280f33c92f11d07217fbe llvm output diff -r 8741552a4e4b -r 5b631c16f89b s-code-llvm.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/s-code-llvm.c Fri Nov 02 14:04:35 2012 +0900 @@ -0,0 +1,226 @@ +/* + Very Simple Code Generator for Intel x86 + $Id$ + */ + + #include "s-compile.h" + +int label = 0; +char *comments = "; "; +static +char *intro[] = { + "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\n", + "target triple = \"x86_64-apple-macosx10.8.0\"\n", + "@.str = private unnamed_addr constant [5 x i8] c\"\0A = \00\", align 1\n", + "define i32 @main() nounwind uwtable ssp {\n", + "entry:\n", + NULL +}; + +static +char *ending[] = { + " ret i32 0\n", + "}\n", + "declare i32 @printf(i8*, ...)\n", + NULL +}; + +static int creg; /* current register */ +static int lreg; /* operand register */ +static int dreg; /* temporary register */ +static int xreg; /* operand register */ +static int reg_sp; /* REGister Stack-Pointer */ + +#define MAX_MAX 20 +static int regs[MAX_MAX]; /* 使われているレジスタを示すフラグ */ +static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ + +const int MAX_REGISTER=20; + +static int +get_register() +{ /* 使われていないレジスタを調べる */ + int i; + for(i=0;i