Skip to content

float32s not working #7

@xplshn

Description

@xplshn
]~/Documents/TrulyMine/gbc_agentic@ cat ./tests/float32.bx
extrn printf;

int main() {
   float32 x, y;
   x = 1.25;
   y = 2.75;
   printf("x = %.3f, y = %.3f\n", x, y);
   return (0);
}
]~/Documents/TrulyMine/gbc_agentic@ ./gbc ./tests/float32.bx
gbc: info: no target specified, defaulting to host target 'amd64_sysv' for backend 'qbe'
gbc: info: using backend 'qbe' with target 'amd64_sysv' (GOOS=linux, GOARCH=amd64)
----------------------
Tokenizing 1 source file(s) (Typed Pass: true)...
Parsing tokens into AST...
Folding constants...
Type checking...
Creating intermediate representation...
Generating code with 'qbe' backend...
Linking to create 'a.out'...
----------------------
Done!
]~/Documents/TrulyMine/gbc_agentic@ ./a.out 
x = 0.000, y = 0.000
]~/Documents/TrulyMine/gbc_agentic@ cat ./tests/float32.bx
extrn printf;

int main() {
   float32 x, y;
   x = 1.25;
   y = 2.75;
   printf("x = %.3f, y = %.3f\n", x, y);
   float a, b;
   a = 8.50;
   b = 7.50;
   printf("a = %.3f, b = %.3f\n", a, b);
   // X and Y once again
   printf("x = %.3f, y = %.3f\n", x, y);
   return (0);
}
]~/Documents/TrulyMine/gbc_agentic@ ./gbc ./tests/float32.bx
gbc: info: no target specified, defaulting to host target 'amd64_sysv' for backend 'qbe'
gbc: info: using backend 'qbe' with target 'amd64_sysv' (GOOS=linux, GOARCH=amd64)
----------------------
Tokenizing 1 source file(s) (Typed Pass: true)...
Parsing tokens into AST...
Folding constants...
Type checking...
Creating intermediate representation...
Generating code with 'qbe' backend...
Linking to create 'a.out'...
----------------------
Done!
]~/Documents/TrulyMine/gbc_agentic@ ./a.out 
x = 0.000, y = 0.000
a = 8.500, b = 7.500
x = 1.250, y = 2.750
]~/Documents/TrulyMine/gbc_agentic@ ./gbc -t llvm ./tests/float32.bx
gbc: info: no target specified, defaulting to host target 'x86_64-unknown-linux-unknown' for backend 'llvm'
gbc: info: using backend 'llvm' with target 'x86_64-unknown-linux-unknown' (GOOS=linux, GOARCH=amd64)
----------------------
Tokenizing 1 source file(s) (Typed Pass: true)...
Parsing tokens into AST...
Folding constants...
Type checking...
Creating intermediate representation...
Generating code with 'llvm' backend...
Linking to create 'a.out'...
----------------------
Done!
]~/Documents/TrulyMine/gbc_agentic@ ./a.out 
x = 0.000, y = 0.000
a = 0.000, b = 0.000
x = 1.250, y = 2.750
]~/Documents/TrulyMine/gbc_agentic@ 

NOTE: Results change if we disable LLVM's optimizations and use -O0 in ./pkg/codegen/llvm_backend.go
NOTE: We may need to add metadata for the optimizer

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions