From daedbda5f131591e47332e06d55dd0d852d862fc Mon Sep 17 00:00:00 2001 From: johti17 <johti17@tlvm-4-1-3.ad.liu.se> Date: Wed, 20 Dec 2023 14:46:14 +0100 Subject: [PATCH] Fixed capitalization expanded Lab 4 instructions slightly README --- lab3-4/README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/lab3-4/README.md b/lab3-4/README.md index fbb110a..f26ba1b 100644 --- a/lab3-4/README.md +++ b/lab3-4/README.md @@ -71,9 +71,58 @@ diff -y my_output.txt ../traces/trace-lab3.txt ## Lab 4 -In lab 4 you will work in file `codegen.cc` search for `/* --- Your code here --- */`' +In Lab 4 you will work in file `codegen.cc` search for `/* --- Your code here --- */`' to see where you need to introduce your changes. +A good place to start is the function `BinaryGenerateCode` + +```C++ +/* + * + * This function is used to generate code for all kinds of binary + * operators and relations. The arguments to the function are the + * following: + * + * q The QuadsList onto which the generated code is placed. + * realop The quad to generate for the operator if the arguments + * are of type real. + * intop The quad to generate for the operator if the arguments + * are of type integer. + * left The AST for the left-hand side of the operator. The + * value type of this AST must be the same as that of the + * AST for the right-hand side. + * right The AST for the right-hand side of the operator. The + * value type of this AST must be the same as that of the + * AST for the left-hand side. + * node The operator node itself. You probably won't need this + * unless you want to print an error message. + * type If not NULL, this is the type of the result. This is + * used for relations, where the type of the result is + * always integer, even if the operands are real. If this + * parameter is NULL, then the type of the result is the + * same as the type of the operands (the parser needs to + * make sure that the operands have the same type.) + * + * See the GenerateCode methods for the binary operators for + * examples of how this function is used. + * + */ + +static VariableInformation *BinaryGenerateCode(QuadsList& q, + tQuadType realop, + tQuadType intop, + ASTNode *left, + ASTNode *right, + ASTNode *node, + TypeInformation *type = NULL) +{ + /* --- Your code here --- */ + return NULL; + /* --- End your code --- */ +} +``` + + ### Testing Lab 4 In order to test Lab 4, there exists a test script. For more details see the README in the test folder. -- GitLab