-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.h
34 lines (30 loc) · 1.43 KB
/
codegen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* codegen --- code generation routines 2022-08-12 */
/* Copyright (c) 2022 John Honniball. All rights reserved */
#include "symtab.h"
#define NOLABEL (-1)
struct StringConstant {
int label;
char str[256];
char sValue[256];
int sLength;
};
void CodeGenInit(void);
bool OpenAssemblerFile(const char fname[]);
bool CloseAssemblerFile(void);
int Emit(const char inst[], const char oper[], const char comment[]);
int AllocLabel(const char purpose);
void EmitLabel(const int label);
void EmitFunctionEntry(const char name[], const int nBytes, const int nRegister);
void EmitFunctionExit(const int returnLabel, const int nRegister);
void EmitStaticCharArray(const struct StringConstant *sc, const char name[]);
void LoadScalar(const struct Symbol *const sym);
void StoreScalar(const struct Symbol *const sym);
void LoadIntConstant(const int val, const int reg, const char comment[]);
void LoadLabelAddr(const int label, const char comment[]);
void EmitExternScalar(const struct Symbol *const sym, const int init, const double fInit);
void EmitJump(const int label, const char comment[]);
void EmitBranchIfEqual(const int label, const char comment[]);
void EmitBranchNotEqual(const int label, const char comment[]);
void EmitIncScalar(const struct Symbol *const sym, const int amount);
void EmitCompareIntConstant(const int compare, const char comment[]);
void EmitCallFunction(const char name[], const char comment[]);