Commit Graph

76 Commits

Author SHA1 Message Date
Jack Palevich a998b1c407 Fix static and shared library usage for acc and accRuntimeTest 2009-11-12 16:06:28 +08:00
Jack Palevich b5d2ad66df Build accRuntimeTest with static library rather than shared library. 2009-11-12 15:38:44 +08:00
Jack Palevich e0f9d91dc7 Skip OTCCANSI test on OS X
OS X can't load stderr/stdin/stdout through the DLL symbol lookup
interface, so it can't compile the otcc-ansi.c test.
2009-11-12 15:21:42 +08:00
Jack Palevich 464407588f Build acc tool with static rather than shared library.
OS X does not allow relative shared library path names in compiled apps,
so we have to create and link with a static library version of libacc.
2009-11-12 14:57:50 +08:00
Jack Palevich 13edb721c0 am 556c60f4: am 51da51a2: am 02effee6: Correctly compute the type of an assignment expression.
Merge commit '556c60f4f27e2a3bfde6a47acf876716ea8d5795'

* commit '556c60f4f27e2a3bfde6a47acf876716ea8d5795':
  Correctly compute the type of an assignment expression.
2009-11-09 16:28:51 -08:00
Jack Palevich 02effee6a9 Correctly compute the type of an assignment expression.
This change enables following types of statements to work correctly:

    a = b = 3;
    if ((a = getchar()) < 0) { ... }

This fixes 2232082 acc: assignment in comparison segfaults
2009-11-09 12:52:45 +08:00
Jack Palevich c951c59232 Add support for the continue statement
Add error check for a break statement that's not inside a loop. (We just
generated bad code before. Oops!)
2009-10-29 15:04:27 -07:00
Jack Palevich ee1f829dd4 Implement typedef. 2009-10-28 16:10:17 -07:00
Jack Palevich 188a5a7a3a Support nested macros. (Still don't support macro arguments.)
Now you can say:

    #define A B
    #define B C
    #define C 4

int x = A;

And it will work as expected.

Print an error message rather than assert when we're expecting a
function value, but don't find one.
2009-10-27 17:23:20 -07:00
Jack Palevich 66d487487f Print out error message when symbol lookup fails. 2009-10-27 13:58:08 -07:00
Doug Kwan ab9ad14429 Add back missing libdl in linker command. The executables here contain call
to function defined in libdl.so but the library is missing the linker commands.
Currently, the library is linked via dependency of another library.  While this
works, it is not the right thing to do.
2009-10-02 12:02:02 -07:00
Jack Palevich 1c60e46e0e Produce error rather than assert when encountering a nested function.
Remove extra '\n' characters from error messages.

Dynamically allocate error message buffer.
2009-09-18 15:03:03 -07:00
Jack Palevich bb3e9c1814 Add a script "accarm" for ad-hoc testing of the ARM acc compiler.
This script copies the test file over to the ARM, runs the acc compiler
on ARM, and then prints out the results.

It also syncs the acc compiler binary over to the ARM.
2009-09-10 12:45:31 -07:00
Jack Palevich d5315573d7 Move ARM disassembler out of libacc and into the acc command-line tool. 2009-09-09 13:19:34 -07:00
Jack Palevich 5fd66ae01e Improve address operator (unary &).
Until now the address operator only worked with simple variables.
Now it works with arbitrary expressions (that are lvalues or function
names). So for example this now works:

struct S { int a[10]};

int f(struct S* p) {
    return &p->a[3];
}
2009-09-04 15:24:23 -07:00
Jack Palevich 9221bcccb3 Preliminary struct and union support.
Working features:
 - struct
 - union
 - nested structs
 - anonymous structs
 - forward declarations
 - '.' and '->'
 - copying structs using '='

Missing features:
 - passing structs by value
 - returning structs by value
 - typedef
 - sizeof

Example:

struct v {float x, y, z, w; };

void add(struct v* result, struct v* a, struct v* b) {
    result->x = a->x + b->x;
    result->y = a->y + b->y;
    result->z = a->z + b->z;
    result->w = a->w + b->w;
}

Reworked size-of and alignment logic to support structs.

Improved encoding of ARM immediate constants.
2009-08-26 16:15:07 -07:00
Jack Palevich c0f253359f Make pointer casting work. 2009-08-25 12:23:43 -07:00
Jack Palevich 0f400c59b8 Add runtime check for whether or not the OTCC-output tests can be run.
This means we don't have to manually specify the --norunotcc flag.
2009-08-25 11:57:13 -07:00
Jack Palevich d3abe3c40d Add a --nox86 flag to allow disabling x86 tests
The x86 tests don't work on non-Linux systems.
2009-08-19 11:12:56 -07:00
Jack Palevich 0a01a5db56 Handle functions with anonymous arguments
Example:

int f(int a, int, int c) {
    return a + c;
}
2009-08-19 10:53:43 -07:00
Jack Palevich 815d8b8fdb Allow redefinition of macros.
Example:

#define A 3
#define A 4

This used to do strange things, but now works as it should.
2009-08-18 18:25:56 -07:00
Jack Palevich 0b1827a5b2 Allow '//'-style comments in #defines. 2009-08-18 17:44:12 -07:00
Jack Palevich 0b2de0de64 Allow parenthesized expressions as the value of defines
For example, this now works:

#define A (1 + 2)

Note that we still don't support defines with argument lists, so this is
still illegal:

#define A(X) (X + 2)

Also in this change: The compiler test script allows command-line
arguments to disable testing on ARM and to disable testing the output
of the old OTCC compiler.

Disabling testing on ARM is handy for developing front-end code when no
device or emulator is available.

Disabling testing OTCC output is handy for some 64-bit Linux environments,
because the original OTCC needs some tweaking to be fully compatible, and
I don't have time to investigate this problem right now.
2009-08-18 16:04:03 -07:00
Jack Palevich 80e4972625 Support 2D arrays. 2009-08-04 15:39:49 -07:00
Jack Palevich b61545096d Implement arrays.
Added check to see that pointer types are compatible when passing function
arguments.
2009-08-04 14:56:09 -07:00
Jack Palevich c9b8ffc389 Add support for "short" data type. 2009-08-03 14:42:57 -07:00
Jack Palevich 96138992ac Fix parsing of function declarations that return pointers.
Check that <op>= only evaluates the left-hand-side once.
2009-07-31 15:58:19 -07:00
Jack Palevich 47cbea9c69 Support brackets for accessing array values.
Don't yet support allocating arrays.
2009-07-31 15:25:53 -07:00
Jack Palevich aaac9284b4 Implement pre-increment / pre-decrement 2009-07-31 14:34:34 -07:00
Jack Palevich 43aaee31b9 Support the comma operator. 2009-07-31 14:01:37 -07:00
Jack Palevich 0c01774816 Implement op=. 2009-07-31 12:00:39 -07:00
Jack Palevich beb4fe95a0 Test multiple levels of pointer indirection. 2009-07-31 11:27:29 -07:00
Jack Palevich 8f361faffc Fix bad ARM code generation for '||' and '&&' operators.
Add tests of '&', '&&', '|' and '||' operators.
2009-07-30 16:19:43 -07:00
Jack Palevich 9f51a26961 Load function symbols using lea syntax.
Use a common code path for ordinary, forward, and indirect calls.
2009-07-29 16:22:26 -07:00
Jack Palevich ddf7c9c141 Implement inc/dec in a more lval-friendly way. 2009-07-29 10:28:18 -07:00
Jack Palevich 89baa2083f Fix the ARM postdecrement operator.
Add a test for ++ and -- so this bug won't happen again.
2009-07-23 11:45:15 -07:00
Jack Palevich 8148c5be54 Coerce R0 to destination type before storing it into a variable. 2009-07-16 18:24:47 -07:00
Jack Palevich 2aaf21f1be Improve numerical constant parsing. 2009-07-15 16:16:37 -07:00
Jack Palevich 8c246a9dc2 Add accRegisterSymbolCallback API to control external symbol linkage.
Until now dlsym was used to lookup external symbols. Now you can
register your own function to be called when an undefined symbol is
used.
2009-07-14 21:14:10 -07:00
Jack Palevich fd3db48e2e Add test for passing floats and doubles as ints, floats, and doubles. 2009-07-14 19:39:36 -07:00
Jack Palevich 37c54bd22e Make forward declarations of external symbols really work.
Until now we had always been treating external variables as "int",
and external functions as int (...);
2009-07-14 18:35:36 -07:00
Jack Palevich a8f427f606 Implement pointer arithmetic. 2009-07-13 18:40:08 -07:00
Jack Palevich 25c0ccaed4 Implement support for "char" local and global variables. 2009-07-13 16:56:28 -07:00
Jack Palevich 45431bc252 Implement general casts and pointer dereferencing.
Prior to this casts and pointer dereferencing were special-cased.
2009-07-13 15:57:26 -07:00
Jack Palevich 59178c0a3d Run tests on both ARM and x86 2009-07-13 14:15:18 -07:00
Jack Palevich b7718b973c Implement floating point for ARM. 2009-07-09 22:00:24 -07:00
Jack Palevich bab8064203 Add x86 floating point test. 2009-07-09 13:54:54 -07:00
Jack Palevich 2a4e1a9f88 Finish implementing x86 floating point
Support floating-point if/while statements: if(1.0) { ... }
Support reading values from float and double pointers.

And some additional error checking.
Detect malformed "return" statements
Detect passing the results of "void" functions as arguments.
2009-07-09 13:34:25 -07:00
Jack Palevich a39749f641 Implement x86 floating point operations
+ unary floating point operation -
 + unary floating point compare: !
 + binary floating point operations +-*/
 + binary floating point comparisons: < <= == != >= >
2009-07-08 20:40:31 -07:00
Jack Palevich 9cbd226960 Implement global, local, and stack based float and double variables. 2009-07-08 16:48:41 -07:00