ACSE 2.0.3
Advanced Compiler System for Education
Loading...
Searching...
No Matches
codegen.c File Reference

Code generation functions implementation. More...

#include <stddef.h>
#include "errors.h"
#include "codegen.h"
#include "scanner.h"
#include "target_info.h"

Go to the source code of this file.

Functions

void validateRegisterId (t_program *program, t_regID r)
t_instructiongenADD (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSUB (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenAND (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenOR (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenXOR (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenMUL (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenDIV (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenREM (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSLL (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSRL (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSRA (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenADDI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSUBI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenANDI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenMULI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenORI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenXORI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenDIVI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenREMI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSLLI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSRLI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSRAI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSEQ (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSNE (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSLT (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSLTU (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSGE (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSGEU (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSGT (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSGTU (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSLE (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSLEU (t_program *program, t_regID rd, t_regID rs1, t_regID rs2)
t_instructiongenSEQI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSNEI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSLTI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSLTIU (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSGEI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSGEIU (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSGTI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSGTIU (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSLEI (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenSLEIU (t_program *program, t_regID rd, t_regID rs1, int immediate)
t_instructiongenJ (t_program *program, t_label *label)
t_instructiongenBEQ (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBNE (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBLT (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBLTU (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBGE (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBGEU (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBGT (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBGTU (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBLE (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenBLEU (t_program *program, t_regID rs1, t_regID rs2, t_label *label)
t_instructiongenLI (t_program *program, t_regID rd, int immediate)
t_instructiongenLA (t_program *program, t_regID rd, t_label *label)
t_instructiongenLW (t_program *program, t_regID rd, int immediate, t_regID rs1)
t_instructiongenSW (t_program *program, t_regID rs2, int immediate, t_regID rs1)
t_instructiongenLWGlobal (t_program *program, t_regID rd, t_label *label)
t_instructiongenSWGlobal (t_program *program, t_regID rs1, t_label *label, t_regID r_temp)
t_instructiongenNOP (t_program *program)
t_instructiongenECALL (t_program *program)
t_instructiongenEBREAK (t_program *program)
t_instructiongenExit0Syscall (t_program *program)
t_instructiongenReadIntSyscall (t_program *program, t_regID rd)
t_instructiongenPrintIntSyscall (t_program *program, t_regID rs1)
t_instructiongenPrintCharSyscall (t_program *program, t_regID rs1)
t_regID genLoadVariable (t_program *program, t_symbol *var)
void genStoreRegisterToVariable (t_program *program, t_symbol *var, t_regID reg)
void genStoreConstantToVariable (t_program *program, t_symbol *var, int val)
t_regID genLoadArrayAddress (t_program *program, t_symbol *array, t_regID rIdx)
t_regID genLoadArrayElement (t_program *program, t_symbol *array, t_regID rIdx)
void genStoreRegisterToArrayElement (t_program *program, t_symbol *array, t_regID rIdx, t_regID rVal)
void genStoreConstantToArrayElement (t_program *program, t_symbol *array, t_regID rIdx, int val)

Detailed Description

Code generation functions implementation.

Definition in file codegen.c.

Function Documentation

◆ genLoadArrayAddress()

t_regID genLoadArrayAddress ( t_program * program,
t_symbol * array,
t_regID rIdx )

Generate instructions that load the address of an array element to a register.

Parameters
programThe program where the array belongs.
arrayThe symbol object that refers to an array.
rIdxRegister that at runtime contains an index into the array.
Returns
The identifier of the register that (at runtime) will contain the address of the array element. If the symbol is not of the correct type, REG_0 is returned instead.

Definition at line 496 of file codegen.c.

◆ validateRegisterId()

void validateRegisterId ( t_program * program,
t_regID r )

Definition at line 11 of file codegen.c.