summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/IroUtil.c
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
commitaec1b8dddc68ecb8288ec6132932e4c7b4bca09f (patch)
tree8138328fe43bcc5fff690dc60caac79aa570ab2b /compiler_and_linker/unsorted/IroUtil.c
parentfcfbafff31869ed808bff0639532db1828660e92 (diff)
downloadMWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.tar.gz
MWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.zip
getting close to done
Diffstat (limited to 'compiler_and_linker/unsorted/IroUtil.c')
-rw-r--r--compiler_and_linker/unsorted/IroUtil.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/compiler_and_linker/unsorted/IroUtil.c b/compiler_and_linker/unsorted/IroUtil.c
index 67edd4b..53e6733 100644
--- a/compiler_and_linker/unsorted/IroUtil.c
+++ b/compiler_and_linker/unsorted/IroUtil.c
@@ -956,10 +956,40 @@ void IRO_ReplaceReferenceWithNode(IROLinear *a, IROLinear *b) {
}
}
-void IRO_GetTemp(IROExpr *expr) {
+VarRecord *IRO_GetTemp(IROExpr *expr) {
+ expr->x8 = create_temp_object(expr->linear->rtype);
+ return IRO_FindVar(expr->x8, 1, 1);
}
IROLinear *IRO_AssignToTemp(IROExpr *expr) {
+ IROLinear *objref;
+ IROLinear *ind;
+ IROLinear *ass;
+
+ objref = IRO_NewLinear(IROLinearOperand);
+ objref->u.node = create_objectrefnode(expr->x8);
+ objref->rtype = objref->u.node->data.objref->type;
+ objref->index = ++IRO_NumLinear;
+ objref->flags |= IROLF_Reffed | IROLF_Assigned | IROLF_Ind;
+
+ ind = IRO_NewLinear(IROLinearOp1Arg);
+ ind->nodetype = EINDIRECT;
+ ind->rtype = expr->linear->rtype;
+ ind->u.monadic = objref;
+ ind->index = ++IRO_NumLinear;
+ ind->flags |= IROLF_Reffed | IROLF_Assigned;
+
+ ass = IRO_NewLinear(IROLinearOp2Arg);
+ ass->nodetype = EASS;
+ ass->u.diadic.left = ind;
+ ass->u.diadic.right = expr->linear;
+ ass->rtype = expr->linear->rtype;
+ ass->index = ++IRO_NumLinear;
+
+ objref->next = ind;
+ ind->next = ass;
+ IRO_PasteAfter(objref, ass, expr->linear);
+ return ass;
}
IROLinear *IRO_FindStart(IROLinear *linear) {
@@ -993,7 +1023,7 @@ void IRO_RemoveCommaNodeFromIR(void) {
if (!linear)
break;
if (linear->nodetype == ECOMMA) {
- linear->u.diadic.left->flags &= ~IROLF_Reffed;
+ linear->u.diadic.left->flags = linear->u.diadic.left->flags & ~IROLF_Reffed;
IRO_LocateFather_Cut_And_Paste_Without_Nopping(linear, linear->u.diadic.right);
linear->type = IROLinearNop;
}
@@ -1200,7 +1230,7 @@ IROLinear *IRO_NewIntConst(CInt64 val, Type *type) {
return linear;
}
-IROLinear *IRO_NewFloatConst(Float val, Type *type) {
+IROLinear *IRO_NewFloatConst(const Float val, Type *type) {
ENode *node;
IROLinear *linear;
@@ -1230,4 +1260,3 @@ void IRO_CheckForUserBreak(void) {
IRO_LastUserBreakTick = COS_GetTicks();
}
}
-