Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compiler-construction
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
User expired
compiler-construction
Commits
86f0d9f4
Commit
86f0d9f4
authored
5 years ago
by
FlorianKrull
Browse files
Options
Downloads
Patches
Plain Diff
Data structure offset
parent
d9353a98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/mcc/assembly_gen.h
+13
-6
13 additions, 6 deletions
include/mcc/assembly_gen.h
src/assembly_gen.c
+3
-3
3 additions, 3 deletions
src/assembly_gen.c
with
16 additions
and
9 deletions
include/mcc/assembly_gen.h
+
13
−
6
View file @
86f0d9f4
...
...
@@ -4,16 +4,21 @@
#include
"mcc/dynamic_array.h"
struct
mcc_assembly_offset
{
char
*
variable
;
int
offset
;
};
struct
mcc_assembly_data
{
int
stack_size
;
int
stack_offset
;
int
array_index
;
int
parameter_counter
;
int
arg_counter
;
int
is_main
;
int
param_offset
;
struct
mcc_assembly_offset
**
offsets
;
};
};
enum
mcc_asm_contant_type
{
MCC_ASM_CONST_FLOAT
,
MCC_ASM_CONST_STRING
};
...
...
@@ -28,4 +33,6 @@ struct mcc_asm_constant {
};
}
void
mcc_asm_print_constant
(
FILE
*
out
,
struct
mcc_asm_constant
*
constant
);
#endif //MCC_ASSEMBLY_GEN_H
This diff is collapsed.
Click to expand it.
src/assembly_gen.c
+
3
−
3
View file @
86f0d9f4
...
...
@@ -9,7 +9,7 @@
#define VARIABLE_SIZE 4
int
compute_stack
(
int
variable_size
)
int
mcc_
compute_stack
(
int
variable_size
)
{
int
stack_size
=
variable_size
*
VARIABLE_SIZE
;
if
(
stack_size
%
16
!=
0
)
{
...
...
@@ -18,7 +18,7 @@ int compute_stack(int variable_size)
return
stack_size
;
}
void
mcc_asm_add_constant
(
struct
mcc_asm_constant
**
entries
,
enum
mcc_asm_con
s
tant_type
type
,
int
*
counter
,
void
*
value
){
void
mcc_asm_add_constant
(
struct
mcc_asm_constant
**
entries
,
enum
mcc_asm_contant_type
type
,
int
*
counter
,
void
*
value
){
struct
mcc_asm_constant
*
add_const
=
(
struct
mcc_asm_constant
*
)
malloc
(
sizeof
(
*
add_const
));
add_const
->
const_type
=
type
;
...
...
@@ -407,5 +407,5 @@ char *mcc_asm_gen(FILE *out, struct mcc_tac *tac)
mcc_asm_print_constant
(
out
,
constants
);
//fprintf(out, ".LCONST%d:\n", i);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment