Skip to content

Commit 91a2309

Browse files
committed
C#: Sync identical files
1 parent 3cca74e commit 91a2309

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,13 @@ class ChiInstruction extends Instruction {
19621962
* Gets the operand that represents the new value written by the memory write.
19631963
*/
19641964
final Instruction getPartial() { result = getPartialOperand().getDef() }
1965+
1966+
/**
1967+
* Gets the bit range `[startBit, endBit)` updated by the partial operand of this `ChiInstruction`.
1968+
*/
1969+
final predicate getUpdatedInterval(int startBit, int endBit) {
1970+
Construction::getIntervalUpdatedByChi(this, startBit, endBit)
1971+
}
19651972
}
19661973

19671974
/**

csharp/ql/src/experimental/ir/implementation/raw/Operand.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, NonPhiMemoryOper
328328
not Construction::isInCycle(useInstr) and
329329
strictcount(Construction::getMemoryOperandDefinition(useInstr, tag, _)) = 1
330330
}
331+
332+
/**
333+
* Holds if the operand totally overlaps with its definition and consumes the
334+
* bit range `[startBitOffset, endBitOffset)`.
335+
*/
336+
predicate getUsedInterval(int startBitOffset, int endBitOffset) {
337+
Construction::getUsedInterval(this, startBitOffset, endBitOffset)
338+
}
331339
}
332340

333341
/**

csharp/ql/src/experimental/ir/implementation/raw/internal/IRConstruction.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ private module Cached {
214214
result = getMemoryOperandDefinition(instr, _, _)
215215
}
216216

217+
/**
218+
* Holds if the partial operand of this `ChiInstruction` updates the bit range
219+
* `[startBitOffset, endBitOffset)` of the total operand.
220+
*/
221+
cached
222+
predicate getIntervalUpdatedByChi(ChiInstruction chi, int startBit, int endBit) { none() }
223+
224+
/**
225+
* Holds if the operand totally overlaps with its definition and consumes the
226+
* bit range `[startBitOffset, endBitOffset)`.
227+
*/
228+
cached
229+
predicate getUsedInterval(Operand operand, int startBit, int endBit) { none() }
230+
217231
/**
218232
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
219233
* through a phi instruction and therefore should be impossible.

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,13 @@ class ChiInstruction extends Instruction {
19621962
* Gets the operand that represents the new value written by the memory write.
19631963
*/
19641964
final Instruction getPartial() { result = getPartialOperand().getDef() }
1965+
1966+
/**
1967+
* Gets the bit range `[startBit, endBit)` updated by the partial operand of this `ChiInstruction`.
1968+
*/
1969+
final predicate getUpdatedInterval(int startBit, int endBit) {
1970+
Construction::getIntervalUpdatedByChi(this, startBit, endBit)
1971+
}
19651972
}
19661973

19671974
/**

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, NonPhiMemoryOper
328328
not Construction::isInCycle(useInstr) and
329329
strictcount(Construction::getMemoryOperandDefinition(useInstr, tag, _)) = 1
330330
}
331+
332+
/**
333+
* Holds if the operand totally overlaps with its definition and consumes the
334+
* bit range `[startBitOffset, endBitOffset)`.
335+
*/
336+
predicate getUsedInterval(int startBitOffset, int endBitOffset) {
337+
Construction::getUsedInterval(this, startBitOffset, endBitOffset)
338+
}
331339
}
332340

333341
/**

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@ private module Cached {
149149
)
150150
}
151151

152+
/**
153+
* Holds if the partial operand of this `ChiInstruction` updates the bit range
154+
* `[startBitOffset, endBitOffset)` of the total operand.
155+
*/
156+
cached
157+
predicate getIntervalUpdatedByChi(ChiInstruction chi, int startBitOffset, int endBitOffset) {
158+
exists(Alias::MemoryLocation location, OldInstruction oldInstruction |
159+
oldInstruction = getOldInstruction(chi.getPartial()) and
160+
location = Alias::getResultMemoryLocation(oldInstruction) and
161+
startBitOffset = Alias::getStartBitOffset(location) and
162+
endBitOffset = Alias::getEndBitOffset(location)
163+
)
164+
}
165+
166+
/**
167+
* Holds if `operand` totally overlaps with its definition and consumes the bit range
168+
* `[startBitOffset, endBitOffset)`.
169+
*/
170+
cached
171+
predicate getUsedInterval(NonPhiMemoryOperand operand, int startBitOffset, int endBitOffset) {
172+
exists(Alias::MemoryLocation location, OldIR::NonPhiMemoryOperand oldOperand |
173+
oldOperand = operand.getUse().(OldInstruction).getAnOperand() and
174+
location = Alias::getOperandMemoryLocation(oldOperand) and
175+
startBitOffset = Alias::getStartBitOffset(location) and
176+
endBitOffset = Alias::getEndBitOffset(location)
177+
)
178+
}
179+
152180
/**
153181
* Holds if `instr` is part of a cycle in the operand graph that doesn't go
154182
* through a phi instruction and therefore should be impossible.

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ MemoryLocation getResultMemoryLocation(Instruction instr) {
7979
MemoryLocation getOperandMemoryLocation(MemoryOperand operand) {
8080
result = getMemoryLocation(getAddressOperandAllocation(operand.getAddressOperand()))
8181
}
82+
83+
/** Gets the start bit offset of a `MemoryLocation`, if any. */
84+
int getStartBitOffset(MemoryLocation location) { none() }
85+
86+
/** Gets the end bit offset of a `MemoryLocation`, if any. */
87+
int getEndBitOffset(MemoryLocation location) { none() }

0 commit comments

Comments
 (0)