Commit Graph

260 Commits

Author SHA1 Message Date
Minero Aoki 9f4a9fc8bc r4753@macbookpro: aamine | 2009-05-07 10:01:52 +0900
* net/loveruby/cflat/compiler/IRGenerator.java: emit statement info for casted stmt.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4186 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:59 +00:00
Minero Aoki 8a57dbbdd8 r4751@macbookpro: aamine | 2009-05-06 18:40:33 +0900
* net/loveruby/cflat/compiler/IRGenerator.java: assignBeforeStmt is useless.  Use assign instead.
 * net/loveruby/cflat/compiler/IRGenerator.java: should be able to create tmp in variable initializers for also function toplevel block.
 * net/loveruby/cflat/compiler/IRGenerator.java: move funcall before stmt.
 * net/loveruby/cflat/compiler/CodeGenerator.java: do not display "(null)" location.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4184 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:57 +00:00
Minero Aoki 98937145c8 r4749@macbookpro: aamine | 2009-05-06 17:08:10 +0900
* net/loveruby/cflat/compiler/CodeGenerator.java: refactoring: rename variables.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4183 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:56 +00:00
Minero Aoki ec4ae3acfd r4747@macbookpro: aamine | 2009-05-06 15:49:51 +0900
* net/loveruby/cflat/asm/Type.java: types should not know signed or not.
 * net/loveruby/cflat/ir/Op.java: have signed/unsigned information.
 * net/loveruby/cflat/compiler/IRGenerator.java: use new op and type.
 * net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
 * net/loveruby/cflat/compiler/TypeChecker.java (FuncallNode): should check optional argument types.
 * net/loveruby/cflat/compiler/CodeGenerator.java: now use simple mov to load values from memory (and cast it later).
 * net/loveruby/cflat/type/TypeTable.java: provide stack value type.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4182 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:53 +00:00
Minero Aoki 12979779e3 r4746@macbookpro: aamine | 2009-05-06 14:53:56 +0900
* net/loveruby/cflat/compiler/IRGenerator.java: isStatement() did not work correctly; e.g. return ++argc failed to return value, because ++argc was wrongly judged as statemen (is really expr).
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4181 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:52 +00:00
Minero Aoki e9beca5096 r4743@macbookpro: aamine | 2009-05-06 14:18:45 +0900
* net/loveruby/cflat/ir/StringValue.java -> Str.java
 * net/loveruby/cflat/ir/IntValue.java -> Int.java
 * net/loveruby/cflat/ir/IRVisitor.java: ditto.
 * net/loveruby/cflat/compiler/IRGenerator.java: ditto.
 * net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4178 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:50 +00:00
Minero Aoki 4a93ac31fb r4732@macbookpro: aamine | 2009-05-04 19:00:37 +0900
* net/loveruby/cflat/compiler/LocalResolver.java: create ToplevelScope, ConstantTable here (instead of creating them in AST).
 * net/loveruby/cflat/ast/AST.java: do not create ToplevelScope, ConstantTable by myself.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4175 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-08 10:40:47 +00:00
Minero Aoki 0f3e2d4609 r4668@macbookpro: aamine | 2009-05-03 22:18:01 +0900
* net/loveruby/cflat/compiler/Compiler.java: new method dumpExpr to dump single expression.
 * net/loveruby/cflat/compiler/CompilerMode.java: add enum value DumpExpr: define new option --dump-expr.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4173 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:16 +00:00
Minero Aoki 3c409c9bf4 r4659@macbookpro: aamine | 2009-05-03 19:08:18 +0900
* net/loveruby/cflat/parser/Parser.jj: sizeof TYPE requires one more lookahead because EXPR of "sizeof EXPR" may have parentheses, too.  We can distinguish type and expr by 1 look ahead, because Head of type() == head of typeref() == head of typeref_base().  typeref_base has unique terminal on head.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4172 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:13 +00:00
Minero Aoki 6f0f6f729b r4633@macbookpro: aamine | 2009-05-02 09:49:27 +0900
* net/loveruby/cflat/compiler/Compiler.java: refactoring: rename constant: programId -> ProgramName.
 * net/loveruby/cflat/compiler/Options.java: ditto.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4170 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:09 +00:00
Minero Aoki 05e1bc273a r4632@macbookpro: aamine | 2009-05-02 09:30:52 +0900
* net/loveruby/cflat/compiler/Compiler.java (commandMain): refactoring: extract method: #buildTarget.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4169 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:07 +00:00
Minero Aoki b8ed3ab439 r4629@macbookpro: aamine | 2009-04-30 22:53:58 +0900
* net/loveruby/cflat/compiler/CodeGenerator.java: remove unused method #doesSpillDX.
 * net/loveruby/cflat/compiler/CodeGenerator.java: add "left" argument to #compileBinaryOp.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4168 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:05 +00:00
Minero Aoki 1c13cc4aa1 r4628@macbookpro: aamine | 2009-04-30 22:19:48 +0900
* net/loveruby/cflat/ast/ConstantTable.java: move under entity/.
 * net/loveruby/cflat/ast/ConstantEntry.java: ditto.
 * net/loveruby/cflat/compiler/CodeGenerator.java: follow it.
 * net/loveruby/cflat/ast/StringLiteralNode.java: follow it.
 * net/loveruby/cflat/ir/StringValue.java: follow it.
 * net/loveruby/cflat/ir/IR.java: follow it.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4167 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:46:03 +00:00
Minero Aoki 730345ab89 r4627@macbookpro: aamine | 2009-04-30 22:06:11 +0900
* net/loveruby/cflat/ast/AbstractAssignNode.java: remove unused setter setLHS.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4166 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:45:59 +00:00
Minero Aoki a5a58d9ef8 r4626@macbookpro: aamine | 2009-04-30 21:49:44 +0900
* net/loveruby/cflat/ast/*.java: remove unused reference to asm.Label.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4165 1b9489fe-b721-0410-924e-b54b9192deb8
2009-05-03 14:45:57 +00:00
Minero Aoki e66d1b59d9 * net/loveruby/cflat/entity: new package.
* net/loveruby/cflat/ast: move Entity and its subclasses under entity/.
* net/loveruby/cflat/ast: move Scope and its subclasses under entity/.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4162 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 17:55:46 +00:00
Minero Aoki 9c1be1e20f * net/loveruby/cflat/ast/DefinedFunction.java: remove unused method #epilogueLabel.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4161 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 17:12:20 +00:00
Minero Aoki 2f7019356a * net/loveruby/cflat/asm/Type.java: new class representing assembly integer types.
* net/loveruby/cflat/asm/*.java: support it.
* net/loveruby/cflat/ir/*.java: support it.
* net/loveruby/cflat/compiler/IRGenerator.java: convert ast Type -> asm Type.
* net/loveruby/cflat/compiler/CodeGenerator.java: use asm Type.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4160 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 17:04:29 +00:00
Minero Aoki 8e8ae12043 * net/loveruby/cflat/compiler/CodeGenerator.java: remove simple delegators (to Assembler).
* net/loveruby/cflat/asm/Assembler.java: add _byte(long), etc.
* net/loveruby/cflat/ir/IR.java: do not export typeTable, provide natural type instead.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4159 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 15:24:36 +00:00
Minero Aoki a5eb1024f9 * net/loveruby/cflat/compiler/IRGenerator.java: use ExprNode#shouldEvalutedToAddress again, it contains complex condition.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4158 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 14:54:52 +00:00
Minero Aoki 82586f9184 * net/loveruby/cflat/ir/Expr.java: show Expr type on dump.
* net/loveruby/cflat/type/FunctionType.java: FunctionType#toString should separate each argument types by ",".


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4157 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 14:39:59 +00:00
Minero Aoki 524db547c6 * net/loveruby/cflat/ir: implement IR#dump.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4156 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 14:35:10 +00:00
Minero Aoki 04f5d8e6cc * net/loveruby/cflat/compiler/IRGenerator.java (BlockNode): static variables are special case.
* net/loveruby/cflat/compiler/IRGenerator.java (SwitchNode): Switch must precedes Case bodies to prevent programs from infinite loop.
* net/loveruby/cflat/compiler/CodeGenerator.java (Bin): fix MOD problem.
* net/loveruby/cflat/compiler/CodeGenerator.java (Bin): fix LSHIFT problem.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4155 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 13:41:19 +00:00
Minero Aoki 0b3098612a * now IR nodes are separated from AST. Sources are compilable but not tested yet.
* ir/*: new classes.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4154 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 13:08:40 +00:00
Minero Aoki eaba86066f * ast/ASTVisitor.java: fork DeclarationVisitor.
* ast/DeclarationVisitor.java: new class.
* compiler/Visitor.java: do not visit declarations.
* compiler/TypeResolver.java: visit declarations explicitly.
* compiler/IRGenerator.java: remove useless declarations acceptor.
* compiler/CodeGenerator.java: ditto.
* ast/Entity.java: accept DeclarationVisitor.
* ast/DefinedFunction.java: ditto.
* ast/UndefinedFunction.java: ditto.
* ast/DefinedVariable.java: ditto.
* ast/UndefinedVariable.java: ditto.
* ast/TypeDefinition.java: ditto.
* ast/StructNode.java: ditto.
* ast/UnionNode.java: ditto.
* ast/TypedefNode.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4153 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 09:09:52 +00:00
Minero Aoki 68a99258e5 * net/loveruby/cflat/compiler/IRGenerator.java (SuffixOp): do not calculate twice. Save expr value and reuse it.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4152 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 08:45:30 +00:00
Minero Aoki f23dd70dd2 * net/loveruby/cflat/compiler/IRGenerator.java: must compile initializer.
* net/loveruby/cflat/compiler/IRGenerator.java: f = &puts generated addr(addr(puts)), so remove redundant AddressNode.
* net/loveruby/cflat/compiler/CodeGenerator.java: now --verbose-asm works.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4151 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 08:25:30 +00:00
Minero Aoki 41e5e61c16 * net/loveruby/cflat/compiler/IRGenerator.java: treat LHS specially and remove AddressNode at the top of the LHS tree (e.g. printf = 0 generates &printf = 0).
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4150 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 07:51:05 +00:00
Minero Aoki e8f10dc3f6 * net/loveruby/cflat/compiler/Simplifier.java -> IRGenerator.java
* net/loveruby/cflat/compiler/Compiler.java: rename class.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4149 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 07:19:33 +00:00
Minero Aoki 732ebf51d4 * net/loveruby/cflat/compiler/Simplifier.java (SwitchNode): missing end label.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4148 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 07:10:29 +00:00
Minero Aoki 9e9f65d6ce * net/loveruby/cflat/ast/FuncallNode.java: make a static funcall really static funcall (not use pointer).
net/loveruby/cflat/compiler/Simplifier.java: set aref result type.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4147 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 06:48:12 +00:00
Minero Aoki 78a2217cd9 * net/loveruby/cflat/ast/FuncallNode.java: detect static call.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4146 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 04:50:57 +00:00
Minero Aoki 1074c0177f * net/loveruby/cflat/compiler/Simplifier.java (While): must loop.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4145 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 04:30:15 +00:00
Minero Aoki 487cf1a714 * net/loveruby/cflat/compiler/Simplifier.java (SuffixOp): too few deref.
* net/loveruby/cflat/compiler/Simplifier.java (MemberNode): should set type.
* net/loveruby/cflat/compiler/Simplifier.java (PtrMemberNode): should set type.
* net/loveruby/cflat/compiler/Simplifier.java (Deref, Addr): should compile child expr.
* net/loveruby/cflat/ast/BinaryOpNode.java (ctor): accept type.
* net/loveruby/cflat/ast/TypeNode.java (location): do not raise exception when no typeRef exist.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4144 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 04:22:42 +00:00
Minero Aoki 99b5be5455 * net/loveruby/cflat/asm/PeepholeOptimizer.java: fix bad operator mnemonic. (fixes 4E)
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4143 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-26 03:18:09 +00:00
Minero Aoki 63170db30b * now many tests work (30/1709 failed).
* net/loveruby/cflat/compiler/Simplifier.java: set location of AssignStmtNode.
* net/loveruby/cflat/compiler/Simplifier.java: allocate tmp variable in scope.
* net/loveruby/cflat/compiler/Simplifier.java: opAssign/inc/dec handling was completely wrong (there still be some problems yet).
* net/loveruby/cflat/compiler/CodeGenerator.java (compileLHS): implemented for IR.
* net/loveruby/cflat/compiler/CodeGenerator.java (loadVarible): implemented for IR.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4142 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 18:52:12 +00:00
Minero Aoki 97fbe0672c * net/loveruby/cflat/ast/IR.java: new class to represents IR.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4141 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 15:39:18 +00:00
Minero Aoki ecdfcff254 * new class Simplifier (it is really a IR generator). Passes compilation, but not tested.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4140 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 14:52:48 +00:00
Minero Aoki 1e80fec3ab * refactoring: rename class: compiler/Simplifier.java -> IRGenerator.java.
* compiler/Compiler.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4139 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 05:57:41 +00:00
Minero Aoki ae4073e7c3 revert r4136 (no IR)
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4138 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-19 05:50:16 +00:00
Minero Aoki 444c8e1bd9 * net/loveruby/cflat/compiler/IRGenerator.java: generates IR (intermediate representation) tree (work is still incomplete but commit for logging).
* net/loveruby/cflat/ir: new package to hold IR tree nodes.
* net/loveruby/cflat/ir/IRTree.java: new class.
* net/loveruby/cflat/ir/Stmt.java: new class.
* net/loveruby/cflat/ir/StmtKind.java: new enum.
* net/loveruby/cflat/ir/Expr.java: new class.
* net/loveruby/cflat/ir/ExprKind.java: new enum.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4136 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 16:53:28 +00:00
Minero Aoki 5a287a7b48 * net/loveruby/cflat/compiler/TypeChecker.java: split IRGenerator.
* net/loveruby/cflat/compiler/IRGenerator.java: new class.
* net/loveruby/cflat/compiler/Compiler.java: call IRGenerator.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4135 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 08:49:23 +00:00
Minero Aoki 8d208c36cc * net/loveruby/cflat/compiler/TypeChecker.java: simplify BinaryOp checking, utilizing destructive methods.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4134 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 07:48:17 +00:00
Minero Aoki f69902e1d7 * net/loveruby/cflat/compiler/Visitor.java: make destructive again.
* net/loveruby/cflat/compiler/TypeResolver.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/compiler/LocalResolver.java: ditto.
* net/loveruby/cflat/compiler/CodeGenerator.java: ditto.
* net/loveruby/cflat/compiler/DereferenceChecker.java: ditto.
* net/loveruby/cflat/compiler/JumpResolver.java: ditto.
* net/loveruby/cflat/ast/AbstractAssignNode.java: ditto.
* net/loveruby/cflat/ast/CondExprNode.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4133 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 07:37:18 +00:00
Minero Aoki d514300aef * net/loveruby/cflat/compiler/Visitor.java: make all return types generic.
* net/loveruby/cflat/compiler/TypeChecker.java: ditto.
* net/loveruby/cflat/ast/*.java: ditto.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4132 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-12 06:31:12 +00:00
Minero Aoki 33dcef983b * net/loveruby/cflat/compiler/Compiler.java: call JumpResolver at last.
* net/loveruby/cflat/compiler/TypeChecker.java: TypeChecker has required ReturnNode.function, provide "current function" by myself.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4131 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-05 22:04:35 +00:00
Minero Aoki 043859df0b * net/loveruby/cflat/ast/ASTVisitor.java: #visit returns a node which has same type with the argument, to allow non-destructive AST rewriting.
* net/loveruby/cflat/ast/*Node.java (#accept): ditto.
* net/loveruby/cflat/compiler/Visitor.java: ditto.
* net/loveruby/cflat/compiler/*.java: ditto.
* net/loveruby/cflat/compiler/TypeChecker.java: make non-destructive.
* net/loveruby/cflat/parser/Parser.jj: use StmtNode/ExprNode instead of Node.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4130 1b9489fe-b721-0410-924e-b54b9192deb8
2009-04-04 14:47:11 +00:00
Minero Aoki b09c3f044f * lib/sizeof_jmpbuf.c: new analysis program.
* lib/Makefile: add a rule to build sizeof_jmpbuf.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4115 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-23 18:43:17 +00:00
Minero Aoki 4cb2818d45 * import/setjmp.hb: new file to support setjmp.
* test: test setjmp.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4113 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-23 17:54:11 +00:00
Minero Aoki f6a1df9142 * introduce virtual stack again, for only local variables and tmp variables. Function arguments use true push & pop.
* --verbose-asm prints stack frame layout in detail.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4110 1b9489fe-b721-0410-924e-b54b9192deb8
2008-12-14 15:05:20 +00:00