Skip to content

Commit

Permalink
Fix wrong instruction for bitwise not (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer authored Sep 6, 2023
1 parent ea32753 commit 5c41994
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .run/spice.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spice" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="build -d -O0 -ir ../../media/test-project/test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spice" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spice">
<configuration default="false" name="spice" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="run -d -O3 -ir ../../media/test-project/test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="spice" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="spice">
<envs>
<env name="SPICE_STD_DIR" value="$PROJECT_DIR$/std" />
</envs>
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ASTBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ std::any ASTBuilder::visitCastExpr(SpiceParser::CastExprContext *ctx) {
auto castExprNode = createNode<CastExprNode>(ctx);

// Enrich
castExprNode->isCasted = ctx->LPAREN();
castExprNode->isCast = ctx->LPAREN();

// Visit children
visitChildren(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ASTNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ class CastExprNode : public ASTNode {
[[nodiscard]] CompileTimeValue getCompileTimeValue() const override;

// Public members
bool isCasted = false;
bool isCast = false;
};

// ==================================================== PrefixUnaryExprNode ======================================================
Expand Down
2 changes: 1 addition & 1 deletion src/irgenerator/GenExpressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ std::any IRGenerator::visitCastExpr(const CastExprNode *node) {
diGenerator.setSourceLocation(node);

// Check if only one operand is present -> loop through
if (!node->isCasted)
if (!node->isCast)
return visit(node->prefixUnaryExpr());

// It is a cast expression
Expand Down
6 changes: 4 additions & 2 deletions src/irgenerator/GenValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ std::any IRGenerator::visitFctCall(const FctCallNode *node) {
if (node->hasArgs) {
argValues.reserve(node->argLst()->args().size());
const std::vector<AssignExprNode *> args = node->argLst()->args();
const std::vector<SymbolType> paramSTypes =
data.isFctPtrCall() ? firstFragEntry->getType().getBaseType().getFunctionParamTypes() : spiceFunc->getParamTypes();
assert(paramSTypes.size() == args.size());
for (size_t i = 0; i < args.size(); i++) {
AssignExprNode *argNode = args.at(i);
SymbolType expectedSTy = data.isFctPtrCall() ? firstFragEntry->getType().getBaseType().getFunctionParamTypes().at(i)
: spiceFunc->paramList.at(i).type;
const SymbolType& expectedSTy = paramSTypes.at(i);
const SymbolType &actualSTy = argNode->getEvaluatedSymbolType(manIdx);

// If the arrays are both of size -1 or 0, they are both pointers and do not need to be cast implicitly
Expand Down
2 changes: 1 addition & 1 deletion src/irgenerator/OpRuleConversionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ LLVMExprResult OpRuleConversionManager::getPrefixBitwiseNotInst(const ASTNode *n
case TY_INT: // fallthrough
case TY_SHORT: // fallthrough
case TY_LONG:
return {.value = builder.CreateNeg(lhsV())};
return {.value = builder.CreateNot(lhsV())};
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/typechecker/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ std::any TypeChecker::visitMultiplicativeExpr(MultiplicativeExprNode *node) {

std::any TypeChecker::visitCastExpr(CastExprNode *node) {
// Check if cast is applied
if (!node->isCasted)
if (!node->isCast)
return visit(node->prefixUnaryExpr());

// Visit source type
Expand Down
4 changes: 1 addition & 3 deletions std/io/cli-subcommand.spice
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public f<int> CliSubcommand.parse(unsigned int argc, string[] argv, int layer =
return EXIT_CODE_SUCCESS;
}

// Check for flags
// Check for options
foreach const CliOption<bool>& boolOption : iterate(this.boolOptions) {
if arg == boolOption.getName() {
bool value = true;
Expand All @@ -72,8 +72,6 @@ public f<int> CliSubcommand.parse(unsigned int argc, string[] argv, int layer =
continue 2; // Continue with next argument
}
}

// Check for other options
foreach const CliOption<string>& stringOption : iterate(this.stringOptions) {
if arg == stringOption.getName() {
// get the argument value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ define private i16 @_Z15lambda.L13C49.018__rt_string.Strings(%struct.String %0,
%7 = sext i16 %6 to i32
%8 = call i32 (ptr, ...) @printf(ptr noundef @printf.str.3, ptr %5, i32 %7)
%9 = load i16, ptr %b, align 2
%10 = sub i16 0, %9
%10 = xor i16 %9, -1
store i16 %10, ptr %3, align 2
ret i16 %10
}
Expand Down

0 comments on commit 5c41994

Please sign in to comment.