Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2021-2024 ChilliBits. All rights reserved. | ||
2 | |||
3 | #include "OpRuleConversionManager.h" | ||
4 | |||
5 | #include <llvm/IR/Module.h> | ||
6 | |||
7 | #include <SourceFile.h> | ||
8 | #include <ast/ASTNodes.h> | ||
9 | #include <driver/Driver.h> | ||
10 | #include <global/GlobalResourceManager.h> | ||
11 | #include <irgenerator/IRGenerator.h> | ||
12 | #include <symboltablebuilder/Scope.h> | ||
13 | |||
14 | namespace spice::compiler { | ||
15 | |||
16 | 678 | OpRuleConversionManager::OpRuleConversionManager(SourceFile *sourceFile, IRGenerator *irGenerator) | |
17 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 676 times.
|
678 | : context(irGenerator->cliOptions.useLTO ? irGenerator->resourceManager.ltoContext : sourceFile->context), |
18 | 678 | builder(sourceFile->builder), irGenerator(irGenerator), stdFunctionManager(irGenerator->stdFunctionManager) {} | |
19 | |||
20 | 205 | LLVMExprResult OpRuleConversionManager::getPlusEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
21 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
22 |
1/2✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
|
331 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
23 |
1/2✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
|
341 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
24 | 284 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
25 | 274 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
26 |
1/2✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
|
205 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
27 |
1/2✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
|
205 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
28 |
1/2✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
|
205 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
29 | |||
30 | // Handle operator overloads | ||
31 |
3/4✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✓ Branch 4 taken 126 times.
|
205 | if (callsOverloadedOpFct(node, opIdx)) |
32 | 79 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
33 | |||
34 |
7/12✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
|
126 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
35 | 21 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
36 |
4/8✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 21 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 | return {.value = builder.CreateFAdd(lhsV(), rhsV())}; |
37 | 15 | case COMB(TY_INT, TY_INT): | |
38 |
8/16✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 15 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 15 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 15 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 15 times.
✗ Branch 21 not taken.
|
15 | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
39 | 7 | case COMB(TY_INT, TY_SHORT): // fallthrough | |
40 | case COMB(TY_INT, TY_LONG): { | ||
41 |
4/8✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
|
7 | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
42 |
7/14✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
|
7 | return {.value = builder.CreateAdd(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
43 | } | ||
44 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
45 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
46 | ✗ | return {.value = builder.CreateAdd(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
47 | } | ||
48 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
49 | ✗ | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
50 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
51 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
52 | ✗ | return {.value = builder.CreateAdd(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
53 | } | ||
54 | 4 | case COMB(TY_LONG, TY_INT): // fallthrough | |
55 | case COMB(TY_LONG, TY_SHORT): { | ||
56 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
4 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
57 |
5/14✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
|
4 | return {.value = builder.CreateAdd(lhsV(), rhsLong, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
58 | } | ||
59 | 78 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
60 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
61 | case COMB(TY_CHAR, TY_CHAR): | ||
62 |
9/16✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 74 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 78 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 78 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 78 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 78 times.
✗ Branch 21 not taken.
|
78 | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
63 | 1 | case COMB(TY_PTR, TY_INT): // fallthrough | |
64 | case COMB(TY_PTR, TY_SHORT): // fallthrough | ||
65 | case COMB(TY_PTR, TY_LONG): { | ||
66 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Type *elementTy = lhsSTy.getContained().toLLVMType(irGenerator->sourceFile); |
67 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | llvm::Value *rhsVExt = builder.CreateIntCast(rhsV(), builder.getInt64Ty(), rhsSTy.isSigned()); |
68 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
|
1 | return {.value = builder.CreateGEP(elementTy, lhsV(), rhsVExt)}; |
69 | } | ||
70 | − | default: // GCOV_EXCL_LINE | |
71 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: +="); // GCOV_EXCL_LINE | |
72 | } | ||
73 |
5/14✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 79 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 79 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 79 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 79 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
284 | } |
74 | |||
75 | 27 | LLVMExprResult OpRuleConversionManager::getMinusEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
76 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
77 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
47 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
78 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
54 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
79 | 34 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
80 | 27 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
81 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
27 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
82 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
27 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
83 |
1/2✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
|
27 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
84 | |||
85 | // Handle operator overloads | ||
86 |
3/4✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 20 times.
|
27 | if (callsOverloadedOpFct(node, opIdx)) |
87 | 7 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
88 | |||
89 |
8/12✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
|
20 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
90 | 2 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
91 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | return {.value = builder.CreateFSub(lhsV(), rhsV())}; |
92 | 4 | case COMB(TY_INT, TY_INT): | |
93 |
8/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
|
4 | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
94 | 2 | case COMB(TY_INT, TY_SHORT): // fallthrough | |
95 | case COMB(TY_INT, TY_LONG): { | ||
96 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
97 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
|
2 | return {.value = builder.CreateSub(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
98 | } | ||
99 | 2 | case COMB(TY_SHORT, TY_INT): { | |
100 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
101 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
|
2 | return {.value = builder.CreateSub(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
102 | } | ||
103 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
104 | ✗ | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
105 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
106 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
107 | ✗ | return {.value = builder.CreateSub(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
108 | } | ||
109 | 4 | case COMB(TY_LONG, TY_INT): // fallthrough | |
110 | case COMB(TY_LONG, TY_SHORT): { | ||
111 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
4 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
112 |
5/14✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
|
4 | return {.value = builder.CreateSub(lhsV(), rhsLong, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
113 | } | ||
114 | 5 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
115 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
116 | case COMB(TY_CHAR, TY_CHAR): | ||
117 |
9/16✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
|
5 | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
118 | 1 | case COMB(TY_PTR, TY_INT): // fallthrough | |
119 | case COMB(TY_PTR, TY_SHORT): // fallthrough | ||
120 | case COMB(TY_PTR, TY_LONG): { | ||
121 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Type *elementTy = lhsSTy.getContained().toLLVMType(irGenerator->sourceFile); |
122 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | llvm::Value *rhsVExt = builder.CreateIntCast(rhsV(), builder.getInt64Ty(), rhsSTy.isSigned()); |
123 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Value *rhsVNeg = builder.CreateNeg(rhsVExt); |
124 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
|
1 | return {.value = builder.CreateGEP(elementTy, lhsV(), rhsVNeg)}; |
125 | } | ||
126 | − | default: // GCOV_EXCL_LINE | |
127 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: -="); // GCOV_EXCL_LINE | |
128 | } | ||
129 |
5/14✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 7 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
34 | } |
130 | |||
131 | 15 | LLVMExprResult OpRuleConversionManager::getMulEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
132 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
133 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
28 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
134 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
30 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
135 | 17 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
136 | 15 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
137 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
138 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
139 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
140 | |||
141 | // Handle operator overloads | ||
142 |
3/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13 times.
|
15 | if (callsOverloadedOpFct(node, opIdx)) |
143 | 2 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
144 | |||
145 |
5/11✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
13 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
146 | 9 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
147 |
4/8✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
|
9 | return {.value = builder.CreateFMul(lhsV(), rhsV())}; |
148 | 1 | case COMB(TY_INT, TY_INT): | |
149 |
8/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
|
1 | return {.value = builder.CreateMul(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
150 | 2 | case COMB(TY_INT, TY_SHORT): // fallthrough | |
151 | case COMB(TY_INT, TY_LONG): { | ||
152 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
153 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
|
2 | return {.value = builder.CreateMul(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
154 | } | ||
155 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
156 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
157 | ✗ | return {.value = builder.CreateMul(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
158 | } | ||
159 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
160 | ✗ | return {.value = builder.CreateMul(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
161 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
162 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
163 | ✗ | return {.value = builder.CreateMul(lhsV(), rhsShort, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
164 | } | ||
165 | ✗ | case COMB(TY_LONG, TY_INT): // fallthrough | |
166 | case COMB(TY_LONG, TY_SHORT): { | ||
167 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
168 | ✗ | return {.value = builder.CreateMul(lhsV(), rhsLong, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
169 | } | ||
170 | 1 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
171 | case COMB(TY_BYTE, TY_BYTE): | ||
172 |
8/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
|
1 | return {.value = builder.CreateMul(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
173 | − | default: // GCOV_EXCL_LINE | |
174 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: *="); // GCOV_EXCL_LINE | |
175 | } | ||
176 |
5/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
17 | } |
177 | |||
178 | 35 | LLVMExprResult OpRuleConversionManager::getDivEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
179 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
180 |
1/2✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
|
38 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
181 |
1/2✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
|
70 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
182 | 67 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
183 | 35 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
184 |
1/2✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
|
35 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
185 |
1/2✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
|
35 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
186 |
1/2✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
|
35 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
187 | |||
188 | // Handle operator overloads | ||
189 |
3/4✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3 times.
|
35 | if (callsOverloadedOpFct(node, opIdx)) |
190 | 32 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
191 | |||
192 |
3/11✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
3 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
193 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
194 | ✗ | return {.value = builder.CreateFDiv(lhsV(), rhsV())}; | |
195 | ✗ | case COMB(TY_INT, TY_INT): | |
196 | ✗ | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsV())}; | |
197 | 2 | case COMB(TY_INT, TY_SHORT): // fallthrough | |
198 | case COMB(TY_INT, TY_LONG): { | ||
199 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
200 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsInt)}; |
201 | } | ||
202 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
203 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
204 | ✗ | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsShort)}; | |
205 | } | ||
206 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
207 | ✗ | return {.value = builder.CreateSDiv(lhsV(), rhsV())}; | |
208 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
209 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
210 | ✗ | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsShort)}; | |
211 | } | ||
212 | ✗ | case COMB(TY_LONG, TY_INT): // fallthrough | |
213 | case COMB(TY_LONG, TY_SHORT): { | ||
214 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
215 | ✗ | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsLong)}; | |
216 | } | ||
217 | 1 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
218 | case COMB(TY_BYTE, TY_BYTE): | ||
219 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = generateDiv(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
220 | − | default: // GCOV_EXCL_LINE | |
221 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: /="); // GCOV_EXCL_LINE | |
222 | } | ||
223 |
5/14✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 32 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
67 | } |
224 | |||
225 | 5 | LLVMExprResult OpRuleConversionManager::getRemEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
226 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
227 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
228 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
229 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
230 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
231 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
232 | |||
233 |
3/11✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
5 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
234 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
235 | ✗ | return {.value = builder.CreateFRem(lhsV(), rhsV())}; | |
236 | 1 | case COMB(TY_INT, TY_INT): | |
237 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | return {.value = builder.CreateSRem(lhsV(), rhsV())}; |
238 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
239 | case COMB(TY_INT, TY_LONG): { | ||
240 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
241 | ✗ | return {.value = builder.CreateSRem(lhsV(), rhsInt)}; | |
242 | } | ||
243 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
244 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
245 | ✗ | return {.value = generateRem(lhsSTy, rhsSTy, lhsV(), rhsShort)}; | |
246 | } | ||
247 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
248 | ✗ | return {.value = builder.CreateSRem(lhsV(), rhsV())}; | |
249 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
250 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
251 | ✗ | return {.value = generateRem(lhsSTy, rhsSTy, lhsV(), rhsShort)}; | |
252 | } | ||
253 | ✗ | case COMB(TY_LONG, TY_INT): // fallthrough | |
254 | case COMB(TY_LONG, TY_SHORT): { | ||
255 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
256 | ✗ | return {.value = generateRem(lhsSTy, rhsSTy, lhsV(), rhsLong)}; | |
257 | } | ||
258 | 4 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
259 | case COMB(TY_BYTE, TY_BYTE): | ||
260 |
3/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
4 | return {.value = generateRem(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
261 | − | default: // GCOV_EXCL_LINE | |
262 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: %="); // GCOV_EXCL_LINE | |
263 | } | ||
264 | 5 | } | |
265 | |||
266 | 1 | LLVMExprResult OpRuleConversionManager::getSHLEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
267 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
268 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
269 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
270 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
271 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
273 | |||
274 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
275 | 1 | case COMB(TY_INT, TY_INT): | |
276 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | return {.value = builder.CreateShl(lhsV(), rhsV())}; |
277 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
278 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
279 | case COMB(TY_SHORT, TY_INT): { | ||
280 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
281 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsInt)}; | |
282 | } | ||
283 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
284 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsV())}; | |
285 | ✗ | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
286 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
287 | case COMB(TY_LONG, TY_SHORT): { | ||
288 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
289 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsLong)}; | |
290 | } | ||
291 | ✗ | case COMB(TY_LONG, TY_LONG): // fallthrough | |
292 | case COMB(TY_BYTE, TY_BYTE): | ||
293 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsV())}; | |
294 | − | default: // GCOV_EXCL_LINE | |
295 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: <<="); // GCOV_EXCL_LINE | |
296 | } | ||
297 | 1 | } | |
298 | |||
299 | 2 | LLVMExprResult OpRuleConversionManager::getSHREqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
300 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
301 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
302 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
303 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
304 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
305 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
306 | |||
307 |
3/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
2 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
308 | 1 | case COMB(TY_INT, TY_INT): | |
309 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
310 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
311 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
312 | case COMB(TY_SHORT, TY_INT): { | ||
313 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
314 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
315 | } | ||
316 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
317 | ✗ | return {.value = builder.CreateLShr(lhsV(), rhsV())}; | |
318 | 1 | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
319 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
320 | case COMB(TY_LONG, TY_SHORT): { | ||
321 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
322 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsLong)}; |
323 | } | ||
324 | ✗ | case COMB(TY_LONG, TY_LONG): // fallthrough | |
325 | case COMB(TY_BYTE, TY_BYTE): | ||
326 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; | |
327 | − | default: // GCOV_EXCL_LINE | |
328 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: >>="); // GCOV_EXCL_LINE | |
329 | } | ||
330 | 2 | } | |
331 | |||
332 | 1 | LLVMExprResult OpRuleConversionManager::getAndEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
333 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
334 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
335 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
336 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
337 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
338 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
339 | |||
340 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
341 | 1 | case COMB(TY_INT, TY_INT): | |
342 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | return {.value = builder.CreateAnd(lhsV(), rhsV())}; |
343 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
344 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
345 | case COMB(TY_SHORT, TY_INT): { | ||
346 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
347 | ✗ | return {.value = builder.CreateAnd(lhsV(), rhsInt)}; | |
348 | } | ||
349 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
350 | ✗ | return {.value = builder.CreateAnd(lhsV(), rhsV())}; | |
351 | ✗ | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
352 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
353 | case COMB(TY_LONG, TY_SHORT): { | ||
354 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
355 | ✗ | return {.value = builder.CreateAnd(lhsV(), rhsLong)}; | |
356 | } | ||
357 | ✗ | case COMB(TY_LONG, TY_LONG): // fallthrough | |
358 | case COMB(TY_BYTE, TY_BYTE): | ||
359 | ✗ | return {.value = builder.CreateAnd(lhsV(), rhsV())}; | |
360 | − | default: // GCOV_EXCL_LINE | |
361 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: &="); // GCOV_EXCL_LINE | |
362 | } | ||
363 | 1 | } | |
364 | |||
365 | 1 | LLVMExprResult OpRuleConversionManager::getOrEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
366 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
367 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
368 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
369 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
370 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
371 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
372 | |||
373 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
374 | 1 | case COMB(TY_INT, TY_INT): | |
375 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | return {.value = builder.CreateOr(lhsV(), rhsV())}; |
376 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
377 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
378 | case COMB(TY_SHORT, TY_INT): { | ||
379 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
380 | ✗ | return {.value = builder.CreateOr(lhsV(), rhsInt)}; | |
381 | } | ||
382 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
383 | ✗ | return {.value = builder.CreateOr(lhsV(), rhsV())}; | |
384 | ✗ | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
385 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
386 | case COMB(TY_LONG, TY_SHORT): { | ||
387 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
388 | ✗ | return {.value = builder.CreateOr(lhsV(), rhsLong)}; | |
389 | } | ||
390 | ✗ | case COMB(TY_LONG, TY_LONG): // fallthrough | |
391 | case COMB(TY_BYTE, TY_BYTE): | ||
392 | ✗ | return {.value = builder.CreateOr(lhsV(), rhsV())}; | |
393 | − | default: // GCOV_EXCL_LINE | |
394 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: |="); // GCOV_EXCL_LINE | |
395 | } | ||
396 | 1 | } | |
397 | |||
398 | 207 | LLVMExprResult OpRuleConversionManager::getXorEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
399 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
400 |
1/2✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
|
414 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
401 |
1/2✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
|
414 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
402 |
1/2✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
|
207 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
403 |
1/2✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
|
207 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
404 |
1/2✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
|
207 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
405 | |||
406 |
2/8✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 207 times.
✗ Branch 8 not taken.
|
207 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
407 | ✗ | case COMB(TY_INT, TY_INT): | |
408 | ✗ | return {.value = builder.CreateXor(lhsV(), rhsV())}; | |
409 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
410 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
411 | case COMB(TY_SHORT, TY_INT): { | ||
412 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
413 | ✗ | return {.value = builder.CreateXor(lhsV(), rhsInt)}; | |
414 | } | ||
415 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
416 | ✗ | return {.value = builder.CreateXor(lhsV(), rhsV())}; | |
417 | ✗ | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
418 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
419 | case COMB(TY_LONG, TY_SHORT): { | ||
420 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
421 | ✗ | return {.value = builder.CreateXor(lhsV(), rhsLong)}; | |
422 | } | ||
423 | 207 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
424 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
425 | case COMB(TY_CHAR, TY_CHAR): | ||
426 |
4/8✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 207 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 207 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 207 times.
✗ Branch 11 not taken.
|
207 | return {.value = builder.CreateXor(lhsV(), rhsV())}; |
427 | − | default: // GCOV_EXCL_LINE | |
428 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: ^="); // GCOV_EXCL_LINE | |
429 | } | ||
430 | 207 | } | |
431 | |||
432 | 31 | LLVMExprResult OpRuleConversionManager::getBitwiseOrInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
433 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
434 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
62 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
435 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
62 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
436 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
437 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
438 | |||
439 |
2/4✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
|
31 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
440 | 31 | case COMB(TY_INT, TY_INT): // fallthrough | |
441 | case COMB(TY_SHORT, TY_SHORT): // fallthrough | ||
442 | case COMB(TY_LONG, TY_LONG): // fallthrough | ||
443 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
444 | case COMB(TY_BOOL, TY_BOOL): | ||
445 |
4/8✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 31 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 31 times.
✗ Branch 11 not taken.
|
62 | return {.value = builder.CreateOr(lhsV(), rhsV())}; |
446 | − | default: // GCOV_EXCL_LINE | |
447 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: |"); // GCOV_EXCL_LINE | |
448 | } | ||
449 | 31 | } | |
450 | |||
451 | 3 | LLVMExprResult OpRuleConversionManager::getBitwiseXorInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
452 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
453 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
454 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
455 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
456 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
457 | |||
458 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
3 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
459 | 3 | case COMB(TY_INT, TY_INT): // fallthrough | |
460 | case COMB(TY_SHORT, TY_SHORT): // fallthrough | ||
461 | case COMB(TY_LONG, TY_LONG): // fallthrough | ||
462 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
463 | case COMB(TY_BOOL, TY_BOOL): | ||
464 |
4/8✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
6 | return {.value = builder.CreateXor(lhsV(), rhsV())}; |
465 | − | default: // GCOV_EXCL_LINE | |
466 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: ^"); // GCOV_EXCL_LINE | |
467 | } | ||
468 | 3 | } | |
469 | |||
470 | 29 | LLVMExprResult OpRuleConversionManager::getBitwiseAndInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
471 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
472 |
1/2✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
|
58 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
473 |
1/2✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
|
58 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
474 |
1/2✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
|
29 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
475 |
1/2✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
|
29 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
476 | |||
477 |
2/4✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
|
29 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
478 | 29 | case COMB(TY_INT, TY_INT): // fallthrough | |
479 | case COMB(TY_SHORT, TY_SHORT): // fallthrough | ||
480 | case COMB(TY_LONG, TY_LONG): // fallthrough | ||
481 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
482 | case COMB(TY_BOOL, TY_BOOL): | ||
483 |
4/8✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 29 times.
✗ Branch 11 not taken.
|
58 | return {.value = builder.CreateAnd(lhsV(), rhsV())}; |
484 | − | default: // GCOV_EXCL_LINE | |
485 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: &"); // GCOV_EXCL_LINE | |
486 | } | ||
487 | 29 | } | |
488 | |||
489 | 2219 | LLVMExprResult OpRuleConversionManager::getEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
490 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
491 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
4166 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
492 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
4216 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
493 | 2491 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
494 | 2441 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
495 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
2219 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
496 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
2219 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
497 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
2219 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
498 |
1/2✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
|
2219 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
499 | |||
500 | // Handle operator overloads | ||
501 |
3/4✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 325 times.
✓ Branch 4 taken 1894 times.
|
2219 | if (callsOverloadedOpFct(node, opIdx)) |
502 | 325 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
503 | |||
504 | // Check if both values are of type pointer | ||
505 |
7/10✓ Branch 1 taken 1894 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 545 times.
✓ Branch 4 taken 1349 times.
✓ Branch 6 taken 545 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 545 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 545 times.
✓ Branch 11 taken 1349 times.
|
1894 | if (lhsSTy.isPtr() && rhsSTy.isPtr()) |
506 |
4/8✓ Branch 1 taken 545 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 545 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 545 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 545 times.
✗ Branch 11 not taken.
|
545 | return {.value = builder.CreateICmpEQ(lhsV(), rhsV())}; |
507 | |||
508 | // Check if lhs is of type pointer and rhs is of type int | ||
509 |
5/8✓ Branch 1 taken 110 times.
✓ Branch 2 taken 1239 times.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 110 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1349 times.
|
1349 | if (lhsT->isPointerTy() && rhsT->isIntegerTy(32)) { |
510 | ✗ | llvm::Value *lhsInt = builder.CreatePtrToInt(lhsV(), rhsT); | |
511 | ✗ | return {.value = builder.CreateICmpEQ(lhsInt, rhsV())}; | |
512 | } | ||
513 | |||
514 | // Check if one value is a string and the other one is a char* | ||
515 |
8/18✓ Branch 1 taken 1349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 1239 times.
✓ Branch 6 taken 110 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1349 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1349 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1349 times.
|
1349 | if ((lhsSTy.is(TY_STRING) && rhsSTy.isPtrTo(TY_CHAR)) || (lhsSTy.isPtrTo(TY_CHAR) && rhsSTy.is(TY_STRING))) { |
516 | // Generate call to the function isRawEqual(string, string) of the string std | ||
517 | ✗ | llvm::Function *opFct = stdFunctionManager.getStringIsRawEqualStringStringFct(); | |
518 | ✗ | llvm::Value *result = builder.CreateCall(opFct, {lhsV(), rhsV()}); | |
519 | ✗ | return {.value = result}; | |
520 | } | ||
521 | |||
522 | // Check for primitive type combinations | ||
523 |
11/25✓ Branch 1 taken 1349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 231 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 9 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 165 times.
✓ Branch 17 taken 632 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 16 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 133 times.
✓ Branch 23 taken 110 times.
✓ Branch 24 taken 16 times.
✗ Branch 25 not taken.
|
1349 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
524 | 30 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
525 |
4/8✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 30 times.
✗ Branch 11 not taken.
|
30 | return {.value = builder.CreateFCmpOEQ(lhsV(), rhsV())}; |
526 | ✗ | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
527 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
528 | case COMB(TY_DOUBLE, TY_LONG): { | ||
529 | ✗ | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); | |
530 | ✗ | return {.value = builder.CreateFCmpOEQ(lhsV(), rhsFP)}; | |
531 | } | ||
532 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
533 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
534 | ✗ | return {.value = builder.CreateFCmpOEQ(lhsFP, rhsV())}; | |
535 | } | ||
536 | 231 | case COMB(TY_INT, TY_INT): | |
537 |
4/8✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 231 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 231 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 231 times.
✗ Branch 11 not taken.
|
231 | return {.value = builder.CreateICmpEQ(lhsV(), rhsV())}; |
538 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
539 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
540 | ✗ | return {.value = builder.CreateICmpEQ(lhsV(), rhsInt)}; | |
541 | } | ||
542 | ✗ | case COMB(TY_INT, TY_LONG): { | |
543 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
544 | ✗ | return {.value = builder.CreateICmpEQ(lhsLong, rhsV())}; | |
545 | } | ||
546 | ✗ | case COMB(TY_INT, TY_BYTE): // fallthrough | |
547 | case COMB(TY_INT, TY_CHAR): { | ||
548 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
549 | ✗ | return {.value = builder.CreateICmpEQ(lhsV(), rhsInt)}; | |
550 | } | ||
551 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
552 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), lhsT); | |
553 | ✗ | return {.value = builder.CreateFCmpOEQ(lhsFP, rhsV())}; | |
554 | } | ||
555 | 7 | case COMB(TY_SHORT, TY_INT): { | |
556 |
4/8✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
|
7 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
557 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
|
7 | return {.value = builder.CreateICmpEQ(lhsInt, rhsV())}; |
558 | } | ||
559 | 9 | case COMB(TY_SHORT, TY_SHORT): | |
560 |
4/8✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
|
9 | return {.value = builder.CreateICmpEQ(lhsV(), rhsV())}; |
561 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
562 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
563 | ✗ | return {.value = builder.CreateICmpEQ(lhsLong, rhsV())}; | |
564 | } | ||
565 | ✗ | case COMB(TY_SHORT, TY_BYTE): // fallthrough | |
566 | case COMB(TY_SHORT, TY_CHAR): { | ||
567 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
568 | ✗ | return {.value = builder.CreateICmpEQ(lhsV(), rhsShort)}; | |
569 | } | ||
570 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
571 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
572 | ✗ | return {.value = builder.CreateFCmpOEQ(lhsFP, rhsV())}; | |
573 | } | ||
574 | 165 | case COMB(TY_LONG, TY_INT): // fallthrough | |
575 | case COMB(TY_LONG, TY_SHORT): { | ||
576 |
4/8✓ Branch 1 taken 165 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 165 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 165 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 165 times.
✗ Branch 11 not taken.
|
165 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
577 |
3/6✓ Branch 1 taken 165 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 165 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 165 times.
✗ Branch 8 not taken.
|
165 | return {.value = builder.CreateICmpEQ(lhsV(), rhsLong)}; |
578 | } | ||
579 | 632 | case COMB(TY_LONG, TY_LONG): | |
580 |
4/8✓ Branch 1 taken 632 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 632 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 632 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 632 times.
✗ Branch 11 not taken.
|
632 | return {.value = builder.CreateICmpEQ(lhsV(), rhsV())}; |
581 | ✗ | case COMB(TY_LONG, TY_BYTE): // fallthrough | |
582 | case COMB(TY_LONG, TY_CHAR): { | ||
583 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
584 | ✗ | return {.value = builder.CreateICmpEQ(lhsV(), rhsLong)}; | |
585 | } | ||
586 | 16 | case COMB(TY_BYTE, TY_INT): // fallthrough | |
587 | case COMB(TY_CHAR, TY_INT): { | ||
588 |
4/8✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
|
16 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
589 |
3/6✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
|
16 | return {.value = builder.CreateICmpEQ(lhsInt, rhsV())}; |
590 | } | ||
591 | ✗ | case COMB(TY_BYTE, TY_SHORT): // fallthrough | |
592 | case COMB(TY_CHAR, TY_SHORT): { | ||
593 | ✗ | llvm::Value *lhsShort = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
594 | ✗ | return {.value = builder.CreateICmpEQ(lhsShort, rhsV())}; | |
595 | } | ||
596 | ✗ | case COMB(TY_BYTE, TY_LONG): // fallthrough | |
597 | case COMB(TY_CHAR, TY_LONG): { | ||
598 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
599 | ✗ | return {.value = builder.CreateICmpEQ(lhsLong, rhsV())}; | |
600 | } | ||
601 | 133 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | |
602 | case COMB(TY_CHAR, TY_CHAR): | ||
603 |
4/8✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 133 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 133 times.
✗ Branch 11 not taken.
|
133 | return {.value = builder.CreateICmpEQ(lhsV(), rhsV())}; |
604 | 110 | case COMB(TY_STRING, TY_STRING): { | |
605 | // Generate call to the function isRawEqual(string, string) of the string std | ||
606 |
1/2✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
|
110 | llvm::Function *opFct = stdFunctionManager.getStringIsRawEqualStringStringFct(); |
607 |
5/10✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 110 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 110 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 110 times.
✗ Branch 15 not taken.
|
110 | llvm::Value *result = builder.CreateCall(opFct, {lhsV(), rhsV()}); |
608 | 110 | return {.value = result}; | |
609 | } | ||
610 | 16 | case COMB(TY_BOOL, TY_BOOL): // fallthrough | |
611 | case COMB(TY_FUNCTION, TY_FUNCTION): // fallthrough | ||
612 | case COMB(TY_PROCEDURE, TY_PROCEDURE): { | ||
613 |
2/4✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
|
16 | const uint64_t typeSize = irGenerator->module->getDataLayout().getTypeSizeInBits(lhsT) / 8; |
614 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | llvm::Function *memcmpFct = stdFunctionManager.getMemcmpFct(); |
615 |
6/12✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 16 times.
✗ Branch 18 not taken.
|
16 | llvm::Value *memcmpResult = builder.CreateCall(memcmpFct, {lhsP(), rhsP(), builder.getInt64(typeSize)}); |
616 |
4/8✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
|
16 | return {.value = builder.CreateICmpEQ(memcmpResult, llvm::ConstantInt::get(context, llvm::APInt(32, 0)))}; |
617 | } | ||
618 | − | default: // GCOV_EXCL_LINE | |
619 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: =="); // GCOV_EXCL_LINE | |
620 | } | ||
621 |
5/14✓ Branch 1 taken 325 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 325 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 325 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 325 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 325 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
2544 | } |
622 | |||
623 | 1216 | LLVMExprResult OpRuleConversionManager::getNotEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
624 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
625 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
2418 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
626 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
2418 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
627 | 1230 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
628 | 1230 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
629 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
1216 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
630 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
1216 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
631 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
1216 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
632 |
1/2✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
|
1216 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
633 | |||
634 | // Handle operator overloads | ||
635 |
3/4✓ Branch 1 taken 1216 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1206 times.
|
1216 | if (callsOverloadedOpFct(node, opIdx)) |
636 | 10 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
637 | |||
638 | // Check if both values are of type pointer | ||
639 |
7/10✓ Branch 1 taken 1206 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 1060 times.
✓ Branch 6 taken 146 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 146 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 146 times.
✓ Branch 11 taken 1060 times.
|
1206 | if (lhsSTy.isPtr() && rhsSTy.isPtr()) |
640 |
4/8✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 146 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 146 times.
✗ Branch 11 not taken.
|
146 | return {.value = builder.CreateICmpNE(lhsV(), rhsV())}; |
641 | |||
642 | // Check if lhs is of type pointer and rhs is of type int | ||
643 |
5/8✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1049 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1060 times.
|
1060 | if (lhsT->isPointerTy() && rhsT->isIntegerTy(32)) { |
644 | ✗ | llvm::Value *lhsInt = builder.CreatePtrToInt(lhsV(), rhsT); | |
645 | ✗ | return {.value = builder.CreateICmpNE(lhsInt, rhsV())}; | |
646 | } | ||
647 | |||
648 | // Check if one value is a string and the other one is a char* | ||
649 |
8/18✓ Branch 1 taken 1060 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 1049 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1060 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1060 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1060 times.
|
1060 | if ((lhsSTy.is(TY_STRING) && rhsSTy.isPtrTo(TY_CHAR)) || (lhsSTy.isPtrTo(TY_CHAR) && rhsSTy.is(TY_STRING))) { |
650 | // Generate call to the function isRawEqual(string, string) of the string std | ||
651 | ✗ | llvm::Function *opFct = stdFunctionManager.getStringIsRawEqualStringStringFct(); | |
652 | ✗ | llvm::Value *result = builder.CreateCall(opFct, {lhsV(), rhsV()}); | |
653 | // Negate the result | ||
654 | ✗ | return {.value = builder.CreateNot(result)}; | |
655 | } | ||
656 | |||
657 |
10/25✓ Branch 1 taken 1060 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 418 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 8 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 504 times.
✓ Branch 23 taken 11 times.
✓ Branch 24 taken 4 times.
✗ Branch 25 not taken.
|
1060 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
658 | 8 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
659 |
4/8✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
8 | return {.value = builder.CreateFCmpONE(lhsV(), rhsV())}; |
660 | ✗ | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
661 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
662 | case COMB(TY_DOUBLE, TY_LONG): { | ||
663 | ✗ | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); | |
664 | ✗ | return {.value = builder.CreateFCmpONE(lhsV(), rhsFP)}; | |
665 | } | ||
666 | 1 | case COMB(TY_INT, TY_DOUBLE): { | |
667 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); |
668 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = builder.CreateFCmpONE(lhsFP, rhsV())}; |
669 | } | ||
670 | 105 | case COMB(TY_INT, TY_INT): | |
671 |
4/8✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 105 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 105 times.
✗ Branch 11 not taken.
|
105 | return {.value = builder.CreateICmpNE(lhsV(), rhsV())}; |
672 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
673 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
674 | ✗ | return {.value = builder.CreateICmpNE(lhsV(), rhsInt)}; | |
675 | } | ||
676 | ✗ | case COMB(TY_INT, TY_LONG): { | |
677 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
678 | ✗ | return {.value = builder.CreateICmpNE(lhsLong, rhsV())}; | |
679 | } | ||
680 | ✗ | case COMB(TY_INT, TY_BYTE): // fallthrough | |
681 | case COMB(TY_INT, TY_CHAR): { | ||
682 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
683 | ✗ | return {.value = builder.CreateICmpNE(lhsV(), rhsInt)}; | |
684 | } | ||
685 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
686 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
687 | ✗ | return {.value = builder.CreateFCmpONE(lhsFP, rhsV())}; | |
688 | } | ||
689 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
690 | ✗ | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
691 | ✗ | return {.value = builder.CreateICmpNE(lhsInt, rhsV())}; | |
692 | } | ||
693 | 1 | case COMB(TY_SHORT, TY_SHORT): | |
694 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | return {.value = builder.CreateICmpNE(lhsV(), rhsV())}; |
695 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
696 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
697 | ✗ | return {.value = builder.CreateICmpNE(lhsLong, rhsV())}; | |
698 | } | ||
699 | ✗ | case COMB(TY_SHORT, TY_BYTE): // fallthrough | |
700 | case COMB(TY_SHORT, TY_CHAR): { | ||
701 | ✗ | llvm::Value *rhsShort = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
702 | ✗ | return {.value = builder.CreateICmpNE(lhsV(), rhsShort)}; | |
703 | } | ||
704 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
705 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
706 | ✗ | return {.value = builder.CreateFCmpONE(lhsFP, rhsV())}; | |
707 | } | ||
708 | ✗ | case COMB(TY_LONG, TY_INT): // fallthrough | |
709 | case COMB(TY_LONG, TY_SHORT): { | ||
710 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
711 | ✗ | return {.value = builder.CreateICmpNE(lhsV(), rhsLong)}; | |
712 | } | ||
713 | 418 | case COMB(TY_LONG, TY_LONG): | |
714 |
4/8✓ Branch 1 taken 418 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 418 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 418 times.
✗ Branch 11 not taken.
|
418 | return {.value = builder.CreateICmpNE(lhsV(), rhsV())}; |
715 | ✗ | case COMB(TY_LONG, TY_BYTE): // fallthrough | |
716 | case COMB(TY_LONG, TY_CHAR): { | ||
717 | ✗ | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
718 | ✗ | return {.value = builder.CreateICmpNE(lhsV(), rhsLong)}; | |
719 | } | ||
720 | 8 | case COMB(TY_BYTE, TY_INT): | |
721 | case COMB(TY_CHAR, TY_INT): { | ||
722 |
4/8✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
8 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
723 |
3/6✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
|
8 | return {.value = builder.CreateICmpNE(lhsInt, rhsV())}; |
724 | } | ||
725 | ✗ | case COMB(TY_BYTE, TY_SHORT): // fallthrough | |
726 | case COMB(TY_CHAR, TY_SHORT): { | ||
727 | ✗ | llvm::Value *lhsShort = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
728 | ✗ | return {.value = builder.CreateICmpNE(lhsShort, rhsV())}; | |
729 | } | ||
730 | ✗ | case COMB(TY_BYTE, TY_LONG): // fallthrough | |
731 | case COMB(TY_CHAR, TY_LONG): { | ||
732 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
733 | ✗ | return {.value = builder.CreateICmpNE(lhsLong, rhsV())}; | |
734 | } | ||
735 | 504 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | |
736 | case COMB(TY_CHAR, TY_CHAR): | ||
737 |
4/8✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 504 times.
✗ Branch 11 not taken.
|
504 | return {.value = builder.CreateICmpNE(lhsV(), rhsV())}; |
738 | 11 | case COMB(TY_STRING, TY_STRING): { | |
739 | // Generate call to the function isRawEqual(string, string) of the string std | ||
740 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | llvm::Function *opFct = stdFunctionManager.getStringIsRawEqualStringStringFct(); |
741 |
5/10✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 11 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 11 times.
✗ Branch 15 not taken.
|
11 | llvm::Value *result = builder.CreateCall(opFct, {lhsV(), rhsV()}); |
742 | // Negate the result | ||
743 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
|
11 | return {.value = builder.CreateNot(result)}; |
744 | } | ||
745 | 4 | case COMB(TY_BOOL, TY_BOOL): // fallthrough | |
746 | case COMB(TY_FUNCTION, TY_FUNCTION): // fallthrough | ||
747 | case COMB(TY_PROCEDURE, TY_PROCEDURE): { | ||
748 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | const uint64_t typeSize = irGenerator->module->getDataLayout().getTypeSizeInBits(lhsT) / 8; |
749 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | llvm::Function *memcmpFct = stdFunctionManager.getMemcmpFct(); |
750 |
6/12✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
|
4 | llvm::Value *memcmpResult = builder.CreateCall(memcmpFct, {lhsP(), rhsP(), builder.getInt64(typeSize)}); |
751 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
4 | return {.value = builder.CreateICmpNE(memcmpResult, llvm::ConstantInt::get(context, llvm::APInt(32, 0)))}; |
752 | } | ||
753 | − | default: // GCOV_EXCL_LINE | |
754 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: !="); // GCOV_EXCL_LINE | |
755 | } | ||
756 |
5/14✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 10 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1226 | } |
757 | |||
758 | 1344 | LLVMExprResult OpRuleConversionManager::getLessInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
759 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
760 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
2688 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
761 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
2688 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
762 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
1344 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
763 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
1344 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
764 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
1344 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
765 |
1/2✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
|
1344 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
766 | |||
767 |
8/16✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 15 times.
✓ Branch 15 taken 1239 times.
✗ Branch 16 not taken.
|
1344 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
768 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
769 | ✗ | return {.value = builder.CreateFCmpOLT(lhsV(), rhsV())}; | |
770 | 10 | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
771 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
772 | case COMB(TY_DOUBLE, TY_LONG): { | ||
773 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); |
774 |
3/6✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
|
10 | return {.value = builder.CreateFCmpOLT(lhsV(), rhsFP)}; |
775 | } | ||
776 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
777 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
778 | ✗ | return {.value = builder.CreateFCmpOLT(lhsFP, rhsV())}; | |
779 | } | ||
780 | 72 | case COMB(TY_INT, TY_INT): | |
781 |
3/6✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 72 times.
✗ Branch 8 not taken.
|
72 | return {.value = generateLT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
782 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
783 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
784 | ✗ | return {.value = generateLT(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
785 | } | ||
786 | 4 | case COMB(TY_INT, TY_LONG): { | |
787 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
4 | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
788 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | return {.value = generateLT(lhsSTy, rhsSTy, lhsLong, rhsV())}; |
789 | } | ||
790 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
791 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
792 | ✗ | return {.value = builder.CreateFCmpOLT(lhsFP, rhsV())}; | |
793 | } | ||
794 | 3 | case COMB(TY_SHORT, TY_INT): { | |
795 |
4/8✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
3 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
796 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | return {.value = generateLT(lhsSTy, rhsSTy, lhsInt, rhsV())}; |
797 | } | ||
798 | 1 | case COMB(TY_SHORT, TY_SHORT): | |
799 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = generateLT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
800 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
801 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
802 | ✗ | return {.value = generateLT(lhsSTy, rhsSTy, lhsLong, rhsV())}; | |
803 | } | ||
804 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
805 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
806 | ✗ | return {.value = builder.CreateFCmpOLT(lhsFP, rhsV())}; | |
807 | } | ||
808 | 15 | case COMB(TY_LONG, TY_INT): // fallthrough | |
809 | case COMB(TY_LONG, TY_SHORT): { | ||
810 |
4/8✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
|
15 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
811 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | return {.value = generateLT(lhsSTy, rhsSTy, lhsV(), rhsLong)}; |
812 | } | ||
813 | 1239 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
814 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
815 | case COMB(TY_CHAR, TY_CHAR): | ||
816 |
3/6✓ Branch 1 taken 1239 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1239 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1239 times.
✗ Branch 8 not taken.
|
1239 | return {.value = generateLT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
817 | − | default: // GCOV_EXCL_LINE | |
818 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: <"); // GCOV_EXCL_LINE | |
819 | } | ||
820 | 1344 | } | |
821 | |||
822 | 222 | LLVMExprResult OpRuleConversionManager::getGreaterInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
823 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
824 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
444 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
825 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
444 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
826 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
222 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
827 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
222 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
828 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
222 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
829 |
1/2✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
|
222 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
830 | |||
831 |
8/16✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 178 times.
✗ Branch 16 not taken.
|
222 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
832 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
833 | ✗ | return {.value = builder.CreateFCmpOGT(lhsV(), rhsV())}; | |
834 | 2 | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
835 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
836 | case COMB(TY_DOUBLE, TY_LONG): { | ||
837 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); |
838 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | return {.value = builder.CreateFCmpOGT(lhsV(), rhsFP)}; |
839 | } | ||
840 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
841 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
842 | ✗ | return {.value = builder.CreateFCmpOGT(lhsFP, rhsV())}; | |
843 | } | ||
844 | 13 | case COMB(TY_INT, TY_INT): | |
845 |
3/6✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
|
13 | return {.value = generateGT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
846 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
847 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
848 | ✗ | return {.value = generateGT(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
849 | } | ||
850 | 10 | case COMB(TY_INT, TY_LONG): { | |
851 |
4/8✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
|
10 | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
852 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | return {.value = generateGT(lhsSTy, rhsSTy, lhsLong, rhsV())}; |
853 | } | ||
854 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
855 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
856 | ✗ | return {.value = builder.CreateFCmpOGT(lhsFP, rhsV())}; | |
857 | } | ||
858 | 6 | case COMB(TY_SHORT, TY_INT): { | |
859 |
4/8✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
|
6 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
860 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | return {.value = generateGT(lhsSTy, rhsSTy, lhsInt, rhsV())}; |
861 | } | ||
862 | 4 | case COMB(TY_SHORT, TY_SHORT): | |
863 |
3/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
4 | return {.value = generateGT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
864 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
865 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
866 | ✗ | return {.value = generateGT(lhsSTy, rhsSTy, lhsLong, rhsV())}; | |
867 | } | ||
868 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
869 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
870 | ✗ | return {.value = builder.CreateFCmpOGT(lhsFP, rhsV())}; | |
871 | } | ||
872 | 9 | case COMB(TY_LONG, TY_INT): // fallthrough | |
873 | case COMB(TY_LONG, TY_SHORT): { | ||
874 |
4/8✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
|
9 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
875 |
2/4✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
9 | return {.value = generateGT(lhsSTy, rhsSTy, lhsV(), rhsLong)}; |
876 | } | ||
877 | 178 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
878 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
879 | case COMB(TY_CHAR, TY_CHAR): | ||
880 |
3/6✓ Branch 1 taken 178 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 178 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 178 times.
✗ Branch 8 not taken.
|
178 | return {.value = generateGT(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
881 | − | default: // GCOV_EXCL_LINE | |
882 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: >"); // GCOV_EXCL_LINE | |
883 | } | ||
884 | 222 | } | |
885 | |||
886 | 236 | LLVMExprResult OpRuleConversionManager::getLessEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
887 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
888 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
472 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
889 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
472 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
890 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
236 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
891 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
236 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
892 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
236 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
893 |
1/2✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
|
236 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
894 | |||
895 |
5/16✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 222 times.
✗ Branch 16 not taken.
|
236 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
896 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
897 | ✗ | return {.value = builder.CreateFCmpOLE(lhsV(), rhsV())}; | |
898 | ✗ | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
899 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
900 | case COMB(TY_DOUBLE, TY_LONG): { | ||
901 | ✗ | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); | |
902 | ✗ | return {.value = builder.CreateFCmpOLE(lhsV(), rhsFP)}; | |
903 | } | ||
904 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
905 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
906 | ✗ | return {.value = builder.CreateFCmpOLE(lhsFP, rhsV())}; | |
907 | } | ||
908 | 11 | case COMB(TY_INT, TY_INT): | |
909 |
3/6✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
|
11 | return {.value = generateLE(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
910 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
911 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
912 | ✗ | return {.value = generateLE(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
913 | } | ||
914 | ✗ | case COMB(TY_INT, TY_LONG): { | |
915 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
916 | ✗ | return {.value = generateLE(lhsSTy, rhsSTy, lhsLong, rhsV())}; | |
917 | } | ||
918 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
919 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
920 | ✗ | return {.value = builder.CreateFCmpOLE(lhsFP, rhsV())}; | |
921 | } | ||
922 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
923 | ✗ | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
924 | ✗ | return {.value = generateLE(lhsSTy, rhsSTy, lhsInt, rhsV())}; | |
925 | } | ||
926 | 2 | case COMB(TY_SHORT, TY_SHORT): | |
927 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | return {.value = generateLE(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
928 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
929 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
930 | ✗ | return {.value = generateLE(lhsSTy, rhsSTy, lhsLong, rhsV())}; | |
931 | } | ||
932 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
933 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
934 | ✗ | return {.value = builder.CreateFCmpOLE(lhsFP, rhsV())}; | |
935 | } | ||
936 | 1 | case COMB(TY_LONG, TY_INT): // fallthrough | |
937 | case COMB(TY_LONG, TY_SHORT): { | ||
938 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
939 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return {.value = generateLE(lhsSTy, rhsSTy, lhsV(), rhsLong)}; |
940 | } | ||
941 | 222 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
942 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
943 | case COMB(TY_CHAR, TY_CHAR): | ||
944 |
3/6✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 222 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 222 times.
✗ Branch 8 not taken.
|
222 | return {.value = generateLE(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
945 | − | default: // GCOV_EXCL_LINE | |
946 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: <="); // GCOV_EXCL_LINE | |
947 | } | ||
948 | 236 | } | |
949 | |||
950 | 514 | LLVMExprResult OpRuleConversionManager::getGreaterEqualInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
951 | LLVMExprResult &rhs, QualType rhsSTy) { | ||
952 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
1028 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
953 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
1028 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
954 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
955 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
956 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
957 |
1/2✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
|
514 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
958 | |||
959 |
7/16✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 141 times.
✓ Branch 15 taken 353 times.
✗ Branch 16 not taken.
|
514 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
960 | 2 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
961 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | return {.value = builder.CreateFCmpOGE(lhsV(), rhsV())}; |
962 | ✗ | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
963 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
964 | case COMB(TY_DOUBLE, TY_LONG): { | ||
965 | ✗ | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); | |
966 | ✗ | return {.value = builder.CreateFCmpOGE(lhsV(), rhsFP)}; | |
967 | } | ||
968 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
969 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
970 | ✗ | return {.value = builder.CreateFCmpOGE(lhsFP, rhsV())}; | |
971 | } | ||
972 | 9 | case COMB(TY_INT, TY_INT): | |
973 |
3/6✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
|
9 | return {.value = generateGE(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
974 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
975 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
976 | ✗ | return {.value = generateGE(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
977 | } | ||
978 | 8 | case COMB(TY_INT, TY_LONG): { | |
979 |
4/8✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
8 | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
980 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | return {.value = generateGE(lhsSTy, rhsSTy, lhsLong, rhsV())}; |
981 | } | ||
982 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
983 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
984 | ✗ | return {.value = builder.CreateFCmpOGE(lhsFP, rhsV())}; | |
985 | } | ||
986 | 1 | case COMB(TY_SHORT, TY_INT): { | |
987 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
988 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | return {.value = generateGE(lhsSTy, rhsSTy, lhsInt, rhsV())}; |
989 | } | ||
990 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
991 | ✗ | return {.value = generateGE(lhsSTy, rhsSTy, lhsV(), rhsV())}; | |
992 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
993 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
994 | ✗ | return {.value = generateGE(lhsSTy, rhsSTy, lhsLong, rhsV())}; | |
995 | } | ||
996 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
997 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
998 | ✗ | return {.value = builder.CreateFCmpOGE(lhsFP, rhsV())}; | |
999 | } | ||
1000 | 141 | case COMB(TY_LONG, TY_INT): // fallthrough | |
1001 | case COMB(TY_LONG, TY_SHORT): { | ||
1002 |
4/8✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 141 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 141 times.
✗ Branch 11 not taken.
|
141 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
1003 |
2/4✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 141 times.
✗ Branch 5 not taken.
|
141 | return {.value = generateGE(lhsSTy, rhsSTy, lhsV(), rhsLong)}; |
1004 | } | ||
1005 | 353 | case COMB(TY_LONG, TY_LONG): // fallthrough | |
1006 | case COMB(TY_BYTE, TY_BYTE): // fallthrough | ||
1007 | case COMB(TY_CHAR, TY_CHAR): | ||
1008 |
3/6✓ Branch 1 taken 353 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 353 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 353 times.
✗ Branch 8 not taken.
|
353 | return {.value = generateGE(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
1009 | − | default: // GCOV_EXCL_LINE | |
1010 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: >="); // GCOV_EXCL_LINE | |
1011 | } | ||
1012 | 514 | } | |
1013 | |||
1014 | 10 | LLVMExprResult OpRuleConversionManager::getShiftLeftInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
1015 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
1016 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
1017 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
1018 | 10 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
1019 | 10 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
1020 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
1021 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
1022 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
1023 | |||
1024 | // Handle operator overloads | ||
1025 |
3/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 9 times.
|
10 | if (callsOverloadedOpFct(node, opIdx)) |
1026 | 1 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
1027 | |||
1028 |
4/10✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
9 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
1029 | 3 | case COMB(TY_INT, TY_INT): | |
1030 |
4/8✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
3 | return {.value = builder.CreateShl(lhsV(), rhsV())}; |
1031 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
1032 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
1033 | case COMB(TY_SHORT, TY_INT): { | ||
1034 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1035 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsInt)}; | |
1036 | } | ||
1037 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
1038 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsV())}; | |
1039 | 1 | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
1040 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
1041 | case COMB(TY_LONG, TY_SHORT): { | ||
1042 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
1043 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = builder.CreateShl(lhsV(), rhsInt)}; |
1044 | } | ||
1045 | 5 | case COMB(TY_LONG, TY_LONG): | |
1046 |
4/8✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
|
5 | return {.value = builder.CreateShl(lhsV(), rhsV())}; |
1047 | ✗ | case COMB(TY_BYTE, TY_INT): // fallthrough | |
1048 | case COMB(TY_BYTE, TY_SHORT): // fallthrough | ||
1049 | case COMB(TY_BYTE, TY_LONG): { | ||
1050 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1051 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsInt)}; | |
1052 | } | ||
1053 | ✗ | case COMB(TY_BYTE, TY_BYTE): | |
1054 | ✗ | return {.value = builder.CreateShl(lhsV(), rhsV())}; | |
1055 | − | default: // GCOV_EXCL_LINE | |
1056 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: <<"); // GCOV_EXCL_LINE | |
1057 | } | ||
1058 |
5/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
11 | } |
1059 | |||
1060 | 5 | LLVMExprResult OpRuleConversionManager::getShiftRightInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
1061 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
1062 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
1063 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
1064 | 5 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
1065 | 5 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
1066 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
1067 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
1068 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
1069 | |||
1070 | // Handle operator overloads | ||
1071 |
3/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 4 times.
|
5 | if (callsOverloadedOpFct(node, opIdx)) |
1072 | 1 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
1073 | |||
1074 |
3/10✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
4 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
1075 | 2 | case COMB(TY_INT, TY_INT): | |
1076 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
1077 | ✗ | case COMB(TY_INT, TY_SHORT): // fallthrough | |
1078 | case COMB(TY_INT, TY_LONG): // fallthrough | ||
1079 | case COMB(TY_SHORT, TY_INT): { | ||
1080 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1081 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
1082 | } | ||
1083 | ✗ | case COMB(TY_SHORT, TY_SHORT): | |
1084 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; | |
1085 | ✗ | case COMB(TY_SHORT, TY_LONG): // fallthrough | |
1086 | case COMB(TY_LONG, TY_INT): // fallthrough | ||
1087 | case COMB(TY_LONG, TY_SHORT): { | ||
1088 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1089 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
1090 | } | ||
1091 | 2 | case COMB(TY_LONG, TY_LONG): | |
1092 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; |
1093 | ✗ | case COMB(TY_BYTE, TY_INT): // fallthrough | |
1094 | case COMB(TY_BYTE, TY_SHORT): // fallthrough | ||
1095 | case COMB(TY_BYTE, TY_LONG): { | ||
1096 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1097 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsInt)}; | |
1098 | } | ||
1099 | ✗ | case COMB(TY_BYTE, TY_BYTE): | |
1100 | ✗ | return {.value = generateSHR(lhsSTy, rhsSTy, lhsV(), rhsV())}; | |
1101 | − | default: // GCOV_EXCL_LINE | |
1102 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: >>"); // GCOV_EXCL_LINE | |
1103 | } | ||
1104 |
5/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
6 | } |
1105 | |||
1106 | 1971 | LLVMExprResult OpRuleConversionManager::getPlusInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
1107 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
1108 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
3897 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
1109 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
3897 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
1110 | 2016 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
1111 | 2016 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
1112 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
1971 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
1113 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
1971 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
1114 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
1971 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
1115 |
1/2✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
|
1971 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
1116 | |||
1117 | // Handle operator overloads | ||
1118 |
3/4✓ Branch 1 taken 1971 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 1925 times.
|
1971 | if (callsOverloadedOpFct(node, opIdx)) |
1119 | 46 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
1120 | |||
1121 |
11/21✓ Branch 1 taken 1925 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 26 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 41 times.
✓ Branch 17 taken 1369 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 414 times.
✗ Branch 21 not taken.
|
1925 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
1122 | 15 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
1123 |
4/8✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
|
15 | return {.value = builder.CreateFAdd(lhsV(), rhsV())}; |
1124 | 17 | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
1125 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
1126 | case COMB(TY_DOUBLE, TY_LONG): { | ||
1127 |
2/4✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
|
17 | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); |
1128 |
3/6✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
|
17 | return {.value = builder.CreateFAdd(lhsV(), rhsFP)}; |
1129 | } | ||
1130 | 1 | case COMB(TY_INT, TY_DOUBLE): { | |
1131 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); |
1132 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = builder.CreateFAdd(lhsFP, rhsV())}; |
1133 | } | ||
1134 | 39 | case COMB(TY_INT, TY_INT): | |
1135 |
9/16✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 39 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 39 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 39 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 39 times.
✗ Branch 21 not taken.
|
39 | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1136 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
1137 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1138 | ✗ | return {.value = builder.CreateAdd(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1139 | } | ||
1140 | 26 | case COMB(TY_INT, TY_LONG): { | |
1141 |
4/8✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 26 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 26 times.
✗ Branch 11 not taken.
|
26 | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
1142 |
5/14✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 11 taken 26 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 26 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 26 times.
✗ Branch 18 not taken.
|
26 | return {.value = builder.CreateAdd(lhsLong, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1143 | } | ||
1144 | ✗ | case COMB(TY_INT, TY_PTR): { | |
1145 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1146 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1147 | } | ||
1148 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
1149 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1150 | ✗ | return {.value = builder.CreateFAdd(lhsFP, rhsV())}; | |
1151 | } | ||
1152 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
1153 | ✗ | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
1154 | ✗ | return {.value = builder.CreateAdd(lhsInt, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1155 | } | ||
1156 | 2 | case COMB(TY_SHORT, TY_SHORT): | |
1157 |
9/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
|
2 | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1158 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
1159 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
1160 | ✗ | return {.value = builder.CreateAdd(lhsLong, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1161 | } | ||
1162 | ✗ | case COMB(TY_SHORT, TY_PTR): { | |
1163 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1164 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1165 | } | ||
1166 | 1 | case COMB(TY_LONG, TY_DOUBLE): { | |
1167 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); |
1168 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | return {.value = builder.CreateFAdd(lhsFP, rhsV())}; |
1169 | } | ||
1170 | 41 | case COMB(TY_LONG, TY_INT): // fallthrough | |
1171 | case COMB(TY_LONG, TY_SHORT): { | ||
1172 |
4/8✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 41 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 41 times.
✗ Branch 11 not taken.
|
41 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
1173 |
8/14✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 22 times.
✓ Branch 6 taken 19 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 41 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 41 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 41 times.
✗ Branch 18 not taken.
|
41 | return {.value = builder.CreateAdd(lhsV(), rhsLong, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1174 | } | ||
1175 | 1369 | case COMB(TY_LONG, TY_LONG): | |
1176 |
10/16✓ Branch 1 taken 1369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 1209 times.
✓ Branch 6 taken 160 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✓ Branch 9 taken 149 times.
✓ Branch 11 taken 1369 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1369 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1369 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1369 times.
✗ Branch 21 not taken.
|
1369 | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1177 | ✗ | case COMB(TY_LONG, TY_PTR): { | |
1178 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1179 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1180 | } | ||
1181 | ✗ | case COMB(TY_BYTE, TY_BYTE): // fallthrough | |
1182 | case COMB(TY_CHAR, TY_CHAR): | ||
1183 | ✗ | return {.value = builder.CreateAdd(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1184 | 414 | case COMB(TY_PTR, TY_INT): // fallthrough | |
1185 | case COMB(TY_PTR, TY_SHORT): // fallthrough | ||
1186 | case COMB(TY_PTR, TY_LONG): { | ||
1187 |
5/10✓ Branch 1 taken 414 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 414 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 414 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 414 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 414 times.
✗ Branch 14 not taken.
|
414 | llvm::Value *rhsExt = builder.CreateIntCast(rhsV(), builder.getInt64Ty(), rhsSTy.isSigned()); |
1188 |
5/10✓ Branch 2 taken 414 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 414 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 414 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 414 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 414 times.
✗ Branch 16 not taken.
|
414 | return {.value = builder.CreateGEP(lhsSTy.getContained().toLLVMType(irGenerator->sourceFile), lhsV(), rhsExt)}; |
1189 | } | ||
1190 | − | default: // GCOV_EXCL_LINE | |
1191 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: +"); // GCOV_EXCL_LINE | |
1192 | } | ||
1193 |
5/14✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 46 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 46 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 46 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
2017 | } |
1194 | |||
1195 | 1144 | LLVMExprResult OpRuleConversionManager::getMinusInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, | |
1196 | LLVMExprResult &rhs, QualType rhsSTy, size_t opIdx) { | ||
1197 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
2288 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
1198 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
2288 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
1199 | 1144 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
1200 | 1144 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
1201 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
1144 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
1202 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
1144 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
1203 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
1144 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
1204 |
1/2✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
|
1144 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
1205 | |||
1206 | // Handle operator overloads | ||
1207 |
3/4✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1143 times.
|
1144 | if (callsOverloadedOpFct(node, opIdx)) |
1208 | 1 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
1209 | |||
1210 |
6/21✓ Branch 1 taken 1143 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 66 times.
✓ Branch 17 taken 1038 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1143 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
1211 | ✗ | case COMB(TY_DOUBLE, TY_DOUBLE): | |
1212 | ✗ | return {.value = builder.CreateFSub(lhsV(), rhsV())}; | |
1213 | 8 | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
1214 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
1215 | case COMB(TY_DOUBLE, TY_LONG): { | ||
1216 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); |
1217 |
3/6✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
|
8 | return {.value = builder.CreateFSub(lhsV(), rhsFP)}; |
1218 | } | ||
1219 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
1220 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1221 | ✗ | return {.value = builder.CreateFSub(lhsFP, rhsV())}; | |
1222 | } | ||
1223 | 29 | case COMB(TY_INT, TY_INT): | |
1224 |
8/16✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 29 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 29 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 29 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 29 times.
✗ Branch 21 not taken.
|
29 | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1225 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
1226 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1227 | ✗ | return {.value = builder.CreateSub(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1228 | } | ||
1229 | ✗ | case COMB(TY_INT, TY_LONG): { | |
1230 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
1231 | ✗ | return {.value = builder.CreateSub(lhsLong, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1232 | } | ||
1233 | ✗ | case COMB(TY_INT, TY_PTR): { | |
1234 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1235 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1236 | } | ||
1237 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
1238 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1239 | ✗ | return {.value = builder.CreateFSub(lhsFP, rhsV())}; | |
1240 | } | ||
1241 | ✗ | case COMB(TY_SHORT, TY_INT): { | |
1242 | ✗ | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
1243 | ✗ | return {.value = builder.CreateSub(lhsInt, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1244 | } | ||
1245 | 2 | case COMB(TY_SHORT, TY_SHORT): | |
1246 |
9/16✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
|
2 | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1247 | ✗ | case COMB(TY_SHORT, TY_LONG): { | |
1248 | ✗ | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); | |
1249 | ✗ | return {.value = builder.CreateSub(lhsLong, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1250 | } | ||
1251 | ✗ | case COMB(TY_SHORT, TY_PTR): { | |
1252 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1253 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1254 | } | ||
1255 | ✗ | case COMB(TY_LONG, TY_DOUBLE): { | |
1256 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1257 | ✗ | return {.value = builder.CreateFSub(lhsFP, rhsV())}; | |
1258 | } | ||
1259 | 66 | case COMB(TY_LONG, TY_INT): // fallthrough | |
1260 | case COMB(TY_LONG, TY_SHORT): { | ||
1261 |
4/8✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 66 times.
✗ Branch 11 not taken.
|
66 | llvm::Value *rhsLong = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); |
1262 |
8/14✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 56 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 66 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 66 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 66 times.
✗ Branch 18 not taken.
|
66 | return {.value = builder.CreateSub(lhsV(), rhsLong, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1263 | } | ||
1264 | 1038 | case COMB(TY_LONG, TY_LONG): | |
1265 |
10/16✓ Branch 1 taken 1038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 816 times.
✓ Branch 6 taken 222 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 78 times.
✓ Branch 9 taken 144 times.
✓ Branch 11 taken 1038 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1038 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1038 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1038 times.
✗ Branch 21 not taken.
|
1038 | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1266 | ✗ | case COMB(TY_LONG, TY_PTR): { | |
1267 | ✗ | llvm::Value *lhsExt = builder.CreateIntCast(lhsV(), builder.getInt64Ty(), lhsSTy.isSigned()); | |
1268 | ✗ | return {.value = builder.CreateGEP(rhsSTy.getContained().toLLVMType(irGenerator->sourceFile), rhsV(), lhsExt)}; | |
1269 | } | ||
1270 | ✗ | case COMB(TY_BYTE, TY_BYTE): // fallthrough | |
1271 | case COMB(TY_CHAR, TY_CHAR): | ||
1272 | ✗ | return {.value = builder.CreateSub(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1273 | ✗ | case COMB(TY_PTR, TY_INT): // fallthrough | |
1274 | case COMB(TY_PTR, TY_SHORT): // fallthrough | ||
1275 | case COMB(TY_PTR, TY_LONG): { | ||
1276 | ✗ | llvm::Value *rhsExt = builder.CreateIntCast(rhsV(), builder.getInt64Ty(), rhsSTy.isSigned()); | |
1277 | ✗ | return {.value = builder.CreateGEP(lhsSTy.getContained().toLLVMType(irGenerator->sourceFile), lhsV(), rhsExt)}; | |
1278 | } | ||
1279 | − | default: // GCOV_EXCL_LINE | |
1280 | − | throw CompilerError(UNHANDLED_BRANCH, "Operator fallthrough: -"); // GCOV_EXCL_LINE | |
1281 | } | ||
1282 |
5/14✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
|
1145 | } |
1283 | |||
1284 | 603 | LLVMExprResult OpRuleConversionManager::getMulInst(const ASTNode *node, LLVMExprResult &lhs, QualType lhsSTy, LLVMExprResult &rhs, | |
1285 | QualType rhsSTy, size_t opIdx) { | ||
1286 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
1201 | ResolverFct lhsV = [&] { return irGenerator->resolveValue(lhsSTy, lhs); }; |
1287 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
1203 | ResolverFct rhsV = [&] { return irGenerator->resolveValue(rhsSTy, rhs); }; |
1288 | 608 | ResolverFct lhsP = [&] { return irGenerator->resolveAddress(lhs); }; | |
1289 | 606 | ResolverFct rhsP = [&] { return irGenerator->resolveAddress(rhs); }; | |
1290 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
603 | lhsSTy = lhsSTy.removeReferenceWrapper(); |
1291 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
603 | rhsSTy = rhsSTy.removeReferenceWrapper(); |
1292 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
603 | llvm::Type *lhsT = lhsSTy.toLLVMType(irGenerator->sourceFile); |
1293 |
1/2✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
|
603 | llvm::Type *rhsT = rhsSTy.toLLVMType(irGenerator->sourceFile); |
1294 | |||
1295 | // Handle operator overloads | ||
1296 |
3/4✓ Branch 1 taken 603 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 594 times.
|
603 | if (callsOverloadedOpFct(node, opIdx)) |
1297 | 9 | return callOperatorOverloadFct<2>(node, {lhsV, lhsP, rhsV, rhsP}, opIdx); | |
1298 | |||
1299 |
9/16✓ Branch 1 taken 594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 460 times.
✓ Branch 15 taken 105 times.
✗ Branch 16 not taken.
|
594 | switch (getTypeCombination(lhsSTy, rhsSTy)) { |
1300 | 10 | case COMB(TY_DOUBLE, TY_DOUBLE): | |
1301 |
4/8✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
|
10 | return {.value = builder.CreateFMul(lhsV(), rhsV())}; |
1302 | 2 | case COMB(TY_DOUBLE, TY_INT): // fallthrough | |
1303 | case COMB(TY_DOUBLE, TY_SHORT): // fallthrough | ||
1304 | case COMB(TY_DOUBLE, TY_LONG): { | ||
1305 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | llvm::Value *rhsFP = generateIToFp(rhsSTy, rhsV(), lhsT); |
1306 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | return {.value = builder.CreateFMul(lhsV(), rhsFP)}; |
1307 | } | ||
1308 | ✗ | case COMB(TY_INT, TY_DOUBLE): { | |
1309 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1310 | ✗ | return {.value = builder.CreateFMul(lhsFP, rhsV())}; | |
1311 | } | ||
1312 | 12 | case COMB(TY_INT, TY_INT): | |
1313 |
9/16✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 12 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 12 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 12 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 12 times.
✗ Branch 21 not taken.
|
12 | return {.value = builder.CreateMul(lhsV(), rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1314 | ✗ | case COMB(TY_INT, TY_SHORT): { | |
1315 | ✗ | llvm::Value *rhsInt = builder.CreateIntCast(rhsV(), lhsT, lhsSTy.isSigned()); | |
1316 | ✗ | return {.value = builder.CreateMul(lhsV(), rhsInt, "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; | |
1317 | } | ||
1318 | 2 | case COMB(TY_INT, TY_LONG): { | |
1319 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *lhsLong = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
1320 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
|
2 | return {.value = builder.CreateMul(lhsLong, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1321 | } | ||
1322 | ✗ | case COMB(TY_SHORT, TY_DOUBLE): { | |
1323 | ✗ | llvm::Value *lhsFP = generateIToFp(lhsSTy, lhsV(), rhsT); | |
1324 | ✗ | return {.value = builder.CreateFMul(lhsFP, rhsV())}; | |
1325 | } | ||
1326 | 2 | case COMB(TY_SHORT, TY_INT): { | |
1327 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | llvm::Value *lhsInt = builder.CreateIntCast(lhsV(), rhsT, rhsSTy.isSigned()); |
1328 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
|
2 | return {.value = builder.CreateMul(lhsInt, rhsV(), "", false, lhsSTy.isSigned() && rhsSTy.isSigned())}; |
1329 | } | ||
1330 | ✗ |