summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* sxtw x__, w__kugwa2016-01-212-2/+2
| | | | | Additional changes: delete white spaces in a blank line
* Handle the case of freeing a tmp on the stackkugwa2016-01-211-21/+63
|
* Save arguments before calling any functionTing-Wei Lan2016-01-201-16/+20
| | | | | We should not skip the argument-saving step for functions without arguments of the special write function.
* Fix the problem of immediates in register.ckugwa2016-01-201-11/+20
|
* Support calling functions with argumentsTing-Wei Lan2016-01-205-33/+257
| | | | | | | | | | | 1. The symbol attribute is modified to allow storing a related register instead of a memory location. 2. Call check_relop_expr() on all scalar function arguments to make sure that type information is available when generating code. 3. calc_array_offset() is modified to accept incomplete arrays, which is used when passing parts of arrays as arguments. 4. It is currently possible to crash the code generator by calling a function with more than 3 arguments.
* Add the missing vim modeline in register.cTing-Wei Lan2016-01-201-0/+2
|
* Fix the problem of initializing local variableskugwa2016-01-191-11/+16
|
* Complete code-gen of for statementkugwa2016-01-181-2/+51
|
* Complete global array referencekugwa2016-01-181-2/+52
|
* Change mul 4 to lsl 2kugwa2016-01-181-11/+4
|
* Use bool to store lock information of a registerTing-Wei Lan2016-01-182-12/+13
| | | | There are only two state: locked and unlocked.
* Fix calc_array_offset()kugwa2016-01-181-14/+18
| | | | Don't use type->array_size[0]
* Callers have to pass extend_name[]HW5kugwa2016-01-033-9/+9
|
* sxt -> sxtwkugwa2016-01-031-17/+23
|
* Add a function to get the name of 64 bit registerskugwa2016-01-033-2/+27
|
* Add missing ccmmc_register_lock() in store_variable()kugwa2016-01-031-0/+2
|
* Complete array reference for storing local variableskugwa2016-01-031-18/+41
|
* Complete array reference for loading local variableskugwa2016-01-031-21/+110
|
* Use adrp and add to address global variablesTing-Wei Lan2016-01-031-4/+6
| | | | This allows using large global arrays.
* Fix linking error caused by missing .align directiveTing-Wei Lan2016-01-031-0/+1
| | | | relocation truncated to fit: R_AARCH64_LD_PREL_LO19 against `.rodata'
* Add missing colons after label namesTing-Wei Lan2016-01-031-5/+5
|
* Don't add a newline when writing a stringTing-Wei Lan2016-01-031-1/+1
|
* fmov -> mov, fmov cannot be used to move integer registersTing-Wei Lan2016-01-031-1/+1
|
* Fix syntax error when accessing global variablesTing-Wei Lan2016-01-031-2/+4
|
* Drop trailing whitespacesTing-Wei Lan2016-01-031-2/+2
|
* Comment and indent code generated by register.ckugwa2016-01-031-6/+14
|
* Apply register managementkugwa2016-01-032-128/+185
|
* Rewrite names for read, fread, and the overloaded write functionTing-Wei Lan2016-01-031-1/+34
|
* Temporarily workaround the wrong return labelTing-Wei Lan2016-01-031-0/+10
|
* Rewrite the name of main function to work with TA's broken toolchainTing-Wei Lan2016-01-031-6/+12
|
* Workaround label name conflict with TA's broken toolchainTing-Wei Lan2016-01-031-1/+2
|
* Add a function to handle function calls to reduce duplicate codeTing-Wei Lan2016-01-031-6/+9
|
* Complete code-gen of if-else statementkugwa2016-01-031-3/+56
|
* Workaround large immediate by loading constant offsets from memoryTing-Wei Lan2016-01-021-4/+12
|
* Free registers after generating condition code in while statementkugwa2016-01-021-0/+6
|
* Generate code for return statementsTing-Wei Lan2016-01-022-17/+39
|
* Floating-point return value is in s0Ting-Wei Lan2016-01-021-2/+9
|
* Complete code-gen of while statementkugwa2016-01-021-2/+34
|
* Remove the assert() in the function call case of generating exprkugwa2016-01-021-1/+1
|
* Fix output to meet asm syntaxkugwa2016-01-021-5/+5
|
* Handle function calls in exprkugwa2016-01-021-1/+4
|
* Generate code for function callskugwa2016-01-022-1/+14
|
* fneg instruction should use floating-point registersTing-Wei Lan2016-01-021-1/+1
|
* div -> sdiv, there is no instruction called divTing-Wei Lan2016-01-021-1/+1
|
* Generate code to initialize variables with constantsTing-Wei Lan2016-01-021-35/+44
| | | | | This implementation only works with single constant. Using expressions as initializers can corrupt values stored on the stack.
* Fill type_value for ID nodes of newly declared variablesTing-Wei Lan2016-01-021-0/+1
|
* No code has to be generated for typedefTing-Wei Lan2016-01-021-1/+2
|
* Suppress a bogus array bound warning for clang and glibcTing-Wei Lan2016-01-021-0/+8
|
* Generate code for expressions and assignmentsTing-Wei Lan2016-01-025-3/+394
|
* Add function prologue and epilogueTing-Wei Lan2016-01-021-2/+8
|
* Use x30 as the frame pointerTing-Wei Lan2016-01-021-0/+1
|
* Add a simple function to check whether an immediate is too largeTing-Wei Lan2016-01-021-8/+12
|
* Add .size and .type to all global symbols except for uninitialized variablesTing-Wei Lan2016-01-021-6/+20
|
* Can allocate many tmpskugwa2016-01-023-38/+118
|
* Immediate is only safe to when the number is <= 4096Ting-Wei Lan2015-12-311-2/+2
|
* Process local variables declared in else blocksTing-Wei Lan2015-12-311-0/+4
|
* Add missing else statement checkkugwa2015-12-311-0/+5
|
* Properly deallocate the register poolTing-Wei Lan2015-12-312-0/+6
|
* Export functions and global variables as global symbolsTing-Wei Lan2015-12-311-4/+9
|
* Use ldr to prevent immediate from becoming too largeTing-Wei Lan2015-12-311-3/+28
|
* Initialize the register poolkugwa2015-12-314-0/+9
| | | | | additional changes: TODO: ccmmc_register_fini()
* Add code for register managementkugwa2015-12-313-0/+155
|
* Statements should not change the fp offsetTing-Wei Lan2015-12-311-13/+11
|
* Generate fp offsets for local variablesTing-Wei Lan2015-12-311-1/+99
|
* Generate code for global variable declarationsTing-Wei Lan2015-12-311-6/+45
|
* Reset the state of the symbol table before generating codeTing-Wei Lan2015-12-311-0/+2
|
* Add the missing vim modeline in code-generation.cTing-Wei Lan2015-12-311-0/+2
|
* Complete the NORMAL_ID case in generate_global_variable()kugwa2015-12-303-1/+34
|
* Add 3 static code-generation functionskugwa2015-12-301-0/+28
|
* Drop any_error from state and add asm_output to stateTing-Wei Lan2015-12-305-12/+12
|
* Add the code-generation phasekugwa2015-12-303-0/+36
|
* Fix error detection in check_call()kugwa2015-12-111-5/+10
| | | | | Additional changes: Fix crash when excuting statement "return; " in a function with return type "void"
* Handle builtin functions: read, fread, writeTing-Wei Lan2015-12-101-0/+25
|
* Check return type when a function returnskugwa2015-12-101-1/+30
| | | | | | Additional changes: 1. Check if a function is redeclared. 2. Add a macro WARNING().
* Complete check_call() and case CCMMC_KIND_STMT_FORkugwa2015-12-101-12/+106
|
* Fix indent of a statement in elsekugwa2015-12-101-1/+1
|
* Detect overflows and underflows when scanning numbersTing-Wei Lan2015-12-101-2/+50
|
* Scalars cannot be used as arrays and arrays cannot be used as scalarsTing-Wei Lan2015-12-091-0/+10
|
* Use regular tree representation in AST drawerTing-Wei Lan2015-12-091-12/+6
| | | | Left-child right-sibling representation is hard to read.
* Draw computed types stored in ASTTing-Wei Lan2015-12-091-0/+36
|
* Check and write computed types for expressions and arraysTing-Wei Lan2015-12-092-7/+181
|
* process_{relop_expr, var_ref} -> check_{relop_expr, var_ref}kugwa2015-12-092-6/+44
|
* Handle array dimension error of function parameterskugwa2015-12-092-9/+17
| | | | | | Additional changes: 1. Check malloc() 2. Add param_node to avoid long lines
* Change ID to var_ref for rule assign_exprkugwa2015-12-091-4/+2
| | | | ccmmc_ast_new_id() is not needed for the rule
* process_{typedef,variable,function} -> decl_{typedef,variable,function}Ting-Wei Lan2015-12-091-9/+9
|
* retrive -> retrieveTing-Wei Lan2015-12-093-7/+7
|
* Fix crash when constant expressions include string literalsTing-Wei Lan2015-12-091-1/+8
|
* Show (void) for functions without argumentsTing-Wei Lan2015-12-091-0/+2
|
* Can declare local variable and write empty statementskugwa2015-12-081-3/+24
|
* Move code for block node into process_block()kugwa2015-12-081-34/+62
| | | | I don't know how to indent beautifully...
* Can declare functions with empty blockskugwa2015-12-081-18/+73
| | | | get_array_size() is modified to handle empty dimension fields.
* Allow using 'type name(void)' to define functions with no argumentTing-Wei Lan2015-12-071-0/+24
|
* Implement checks for global variable initalizersTing-Wei Lan2015-12-071-46/+185
| | | | | Function eval_const_expr should accept all kinds of operators and reject non-constant expressions properly.
* Reject void variables and void arrays.Ting-Wei Lan2015-12-071-0/+11
|
* Write results to AST nodes when evaluating constant expressionsTing-Wei Lan2015-12-072-88/+93
| | | | This commit also add a macro to reduce duplicate code.
* Allow using typedef with array typesTing-Wei Lan2015-12-071-4/+15
| | | | | | Our parser only allows using typedef with int, float, void, so there should be no user-visible change in this commit. It just makes process_typedef and process_variable look similar.
* Fix unhandled enumeration value errorTing-Wei Lan2015-12-071-0/+1
|
* Use stdin if the source file name is a single dashTing-Wei Lan2015-12-071-1/+2
|
* Allow dumping symbol table via an environment variableTing-Wei Lan2015-12-071-1/+14
|
* Fix problems caused by short-circuit evaluationTing-Wei Lan2015-12-071-4/+4
| | | | The semantic checker should not stop or skip tests when an error is found.
* Handle constant expressions with integer division by zeroTing-Wei Lan2015-12-072-5/+11
|
* Re-add line number fields in AST nodesTing-Wei Lan2015-12-074-152/+225
| | | | It is required to show line numbers in error messages.
* Implement semantic checks for type and variable declarationsTing-Wei Lan2015-12-065-2/+434
|
* Add a flag to mark whether the type is a functionTing-Wei Lan2015-12-061-3/+16
|
* Simple coding style fixTing-Wei Lan2015-12-061-1/+1
|
* Fix typo in ast.hTing-Wei Lan2015-12-061-2/+2
|
* We are going to do semantic analysisTing-Wei Lan2015-12-065-0/+42
|
* Fix indent and broken include guard in state.[ch]Ting-Wei Lan2015-12-062-11/+13
|
* Disable AST dumping by defaultTing-Wei Lan2015-12-061-1/+3
| | | | This feature is still available through defining environment variable.
* Use multiple small hash tables to implement symbol tablesTing-Wei Lan2015-12-063-80/+116
| | | | The scanner no longer modifies the symbol table when finding identifiers.
* Drop all non-namespaced symbolsTing-Wei Lan2015-12-039-504/+523
| | | | | | | | | | | | | | 1. All data types and macros in headers, global variables and functions that have external linkage are namespaced. The only two files that allow non-namespaced symbols are main.c and common.h. common.h should not be included by any other headers. 2. Coding style is fixed when possible. 3. Drop unused variables or struct members. 4. 'name' macro is renamed to 'prog_name' to prevent conflicts with ast.h. 5. %union includes a CON_Type (now CcmmcValueConst) instead of a pointer to it. This prevents an unnecessary malloc. 6. Fix buffer overflow in draw.c. draw.c should not modify the input AST while generating the graph.
* Drop line_number and prog global variablesTing-Wei Lan2015-12-026-34/+78
| | | | | All important states should be stored in the local struct allocated in main function.
* Make the scanner and the parser reentrant and reduce non-namespaced symbolsTing-Wei Lan2015-12-013-19/+52
|
* Sort the list of tokens and non-terminalsTing-Wei Lan2015-11-301-15/+18
|
* Use strerror_r to make error messages more usefulTing-Wei Lan2015-11-303-19/+89
| | | | | This commit adds a new file, common.h, which contains private macros and static functions to make the code cleaner.
* The style of grammer rules is more consistent nowTing-Wei Lan2015-11-301-129/+130
|
* Drop tab usage in source filesTing-Wei Lan2015-11-302-63/+63
|
* Drop unused codeTing-Wei Lan2015-11-301-7/+1
|
* All source files should include vim modelinesTing-Wei Lan2015-11-304-0/+7
|
* Include our headers before including system headersTing-Wei Lan2015-11-306-8/+15
|
* Don't include lexer.c and move yyerror to the end of fileTing-Wei Lan2015-11-302-11/+13
|
* Enable POSIX extensionsTing-Wei Lan2015-11-135-0/+19
|
* Fix the build with --enable-compile-warnings=errorTing-Wei Lan2015-11-133-31/+41
| | | | | | 1. Add missing 'const' keyword for string literals. 2. Add missing 'static' keyword for internal functions. 3. Add missing default cases for switch statements.
* Implement IF and IF...ELSE statementskugwa2015-11-131-5/+7
| | | | | 1. Use "%right DL_RPAREN ELSE" to solve SR conflict. 2. Fix a bug in assign_expr: token ID is not an AST_NODE.
* Complete rules and actions for remaining operators and arraysTing-Wei Lan2015-11-131-26/+84
| | | | | | 1. Actions for binary operators are completed. 2. Rules and actions for unary operators are added. 3. Arrays can be used in expressions now.
* Complete most of the semantic actions before relop_exprkugwa2015-11-131-47/+81
| | | | | if and if-then-else have not been implemented. Some actions after relop_expr is done for the test of for loop.
* Fix some actions to meet TA's speckugwa2015-11-131-10/+5
| | | | | | | | 1. dim_fn should be the child of ID 2. decl_list should be the child of VARIABLE_DECL_LIST_NODE 3. stmt_list should be the child of STMT_LIST_NODE 4. Add actions for decl_list 5. ID with initial value should use WITH_INIT_ID instead of NORMAL_ID
* Add declaration of printGV() in main.ckugwa2015-11-121-0/+2
|
* It finally works for some simple programskugwa2015-11-121-21/+43
| | | | Complete actions of some nonterminals derived from global_decl.
* main() prints the parse treekugwa2015-11-122-0/+203
|
* Token ID fills yylvalkugwa2015-11-121-0/+5
|
* Constant tokens fill yylval and return CONSTkugwa2015-11-121-5/+24
|
* Merge TA's codes to ourskugwa2015-11-117-130/+917
| | | | | | Delete tmp funtion used in HW2. Move AST functions into ast.c. CONST_INT, CONST_FLOAT, and CONST_STRING all return CONST.
* Don't define [+-]? for CONST_INT and CONST_FLOATkugwa2015-11-111-3/+2
|
* Make sure we don't accidently change the number of reserved wordsTing-Wei Lan2015-11-111-0/+5
|
* All actions in lexer.l return the currect tokenkugwa2015-11-111-27/+47
| | | | | Define tokens in enum for reserved words and the action of {ID} will return the currect token. Other actions also return tokens.
* Change the action of the comment tokenkugwa2015-11-091-1/+6
| | | | Don't print comment. line_number increases when there are newlines in the comment.
* Move all source files to the new src directoryTing-Wei Lan2015-11-094-0/+311