-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++/C#: Remove Instruction::getResultType()
and friends
#2217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dave-bartolomeo
wants to merge
3
commits into
github:main
Choose a base branch
from
dave-bartolomeo:dave/RangeType
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ module InstructionSanity { | |
|
||
query predicate missingOperandType(Operand operand, string message) { | ||
exists(Language::Function func, Instruction use | | ||
not exists(operand.getType()) and | ||
not exists(operand.getLanguageType()) and | ||
use = operand.getUse() and | ||
func = use.getEnclosingFunction() and | ||
message = "Operand '" + operand.toString() + "' of instruction '" + use.getOpcode().toString() | ||
|
@@ -455,52 +455,11 @@ class Instruction extends Construction::TInstruction { | |
*/ | ||
final IRType getResultIRType() { result = getResultLanguageType().getIRType() } | ||
|
||
/** | ||
* Gets the type of the result produced by this instruction. If the | ||
* instruction does not produce a result, its result type will be `VoidType`. | ||
* | ||
* If `isGLValue()` holds, then the result type of this instruction should be | ||
* thought of as "pointer to `getResultType()`". | ||
*/ | ||
final Language::Type getResultType() { | ||
exists(Language::LanguageType resultType | | ||
resultType = getResultLanguageType() and | ||
( | ||
resultType.hasUnspecifiedType(result, _) | ||
or | ||
not resultType.hasUnspecifiedType(_, _) and result instanceof Language::UnknownType | ||
) | ||
) | ||
} | ||
|
||
/** | ||
* Holds if the result produced by this instruction is a glvalue. If this | ||
* holds, the result of the instruction represents the address of a location, | ||
* and the type of the location is given by `getResultType()`. If this does | ||
* not hold, the result of the instruction represents a value whose type is | ||
* given by `getResultType()`. | ||
* | ||
* For example, the statement `y = x;` generates the following IR: | ||
* r1_0(glval: int) = VariableAddress[x] | ||
* r1_1(int) = Load r1_0, mu0_1 | ||
* r1_2(glval: int) = VariableAddress[y] | ||
* mu1_3(int) = Store r1_2, r1_1 | ||
* | ||
* The result of each `VariableAddress` instruction is a glvalue of type | ||
* `int`, representing the address of the corresponding integer variable. The | ||
* result of the `Load` instruction is a prvalue of type `int`, representing | ||
* the integer value loaded from variable `x`. | ||
*/ | ||
final predicate isGLValue() { Construction::getInstructionResultType(this).hasType(_, true) } | ||
|
||
/** | ||
* Gets the size of the result produced by this instruction, in bytes. If the | ||
* result does not have a known constant size, this predicate does not hold. | ||
* | ||
* If `this.isGLValue()` holds for this instruction, the value of | ||
* `getResultSize()` will always be the size of a pointer. | ||
*/ | ||
final int getResultSize() { result = Construction::getInstructionResultType(this).getByteSize() } | ||
final int getResultSize() { result = getResultLanguageType().getByteSize() } | ||
|
||
/** | ||
* Gets the opcode that specifies the operation performed by this instruction. | ||
|
@@ -799,11 +758,13 @@ class ConstantInstruction extends ConstantValueInstruction { | |
} | ||
|
||
class IntegerConstantInstruction extends ConstantInstruction { | ||
IntegerConstantInstruction() { getResultType() instanceof Language::IntegralType } | ||
IntegerConstantInstruction() { | ||
getResultIRType() instanceof IRIntegerType or getResultIRType() instanceof IRBooleanType | ||
} | ||
} | ||
|
||
class FloatConstantInstruction extends ConstantInstruction { | ||
FloatConstantInstruction() { getResultType() instanceof Language::FloatingPointType } | ||
FloatConstantInstruction() { getResultIRType() instanceof IRFloatingPointType } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would tend to prefer |
||
} | ||
|
||
class StringConstantInstruction extends Instruction { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A line break would make this clearer.