@@ -30,7 +30,7 @@ module InstructionSanity {
3030 or
3131 opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag
3232 or
33- opcode instanceof BufferAccessOpcode and tag instanceof BufferSizeOperand
33+ opcode instanceof SizedBufferAccessOpcode and tag instanceof BufferSizeOperandTag
3434 or
3535 opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag
3636 or
@@ -48,8 +48,8 @@ module InstructionSanity {
4848 or
4949 (
5050 opcode instanceof ReadSideEffectOpcode or
51- opcode instanceof MayWriteSideEffectOpcode or
52- opcode instanceof Opcode:: InlineAsm
51+ opcode instanceof Opcode :: InlineAsm or
52+ opcode instanceof Opcode:: CallSideEffect
5353 ) and
5454 tag instanceof SideEffectOperandTag
5555 )
@@ -609,7 +609,7 @@ class VariableInstruction extends Instruction {
609609
610610 VariableInstruction ( ) { var = Construction:: getInstructionVariable ( this ) }
611611
612- final override string getImmediateString ( ) { result = var .toString ( ) }
612+ override string getImmediateString ( ) { result = var .toString ( ) }
613613
614614 final IRVariable getVariable ( ) { result = var }
615615}
@@ -644,6 +644,16 @@ class ConstantValueInstruction extends Instruction {
644644 final string getValue ( ) { result = value }
645645}
646646
647+ class IndexedInstruction extends Instruction {
648+ int index ;
649+
650+ IndexedInstruction ( ) { index = Construction:: getInstructionIndex ( this ) }
651+
652+ final override string getImmediateString ( ) { result = index .toString ( ) }
653+
654+ final int getIndex ( ) { result = index }
655+ }
656+
647657class EnterFunctionInstruction extends Instruction {
648658 EnterFunctionInstruction ( ) { getOpcode ( ) instanceof Opcode:: EnterFunction }
649659}
@@ -1175,20 +1185,48 @@ class CallReadSideEffectInstruction extends SideEffectInstruction {
11751185 */
11761186class IndirectReadSideEffectInstruction extends SideEffectInstruction {
11771187 IndirectReadSideEffectInstruction ( ) { getOpcode ( ) instanceof Opcode:: IndirectReadSideEffect }
1188+
1189+ Instruction getArgumentDef ( ) { result = getAnOperand ( ) .( AddressOperand ) .getDef ( ) }
11781190}
11791191
11801192/**
11811193 * An instruction representing the read of an indirect buffer parameter within a function call.
11821194 */
11831195class BufferReadSideEffectInstruction extends SideEffectInstruction {
11841196 BufferReadSideEffectInstruction ( ) { getOpcode ( ) instanceof Opcode:: BufferReadSideEffect }
1197+
1198+ Instruction getArgumentDef ( ) { result = getAnOperand ( ) .( AddressOperand ) .getDef ( ) }
1199+ }
1200+
1201+ /**
1202+ * An instruction representing the read of an indirect buffer parameter within a function call.
1203+ */
1204+ class SizedBufferReadSideEffectInstruction extends SideEffectInstruction {
1205+ SizedBufferReadSideEffectInstruction ( ) {
1206+ getOpcode ( ) instanceof Opcode:: SizedBufferReadSideEffect
1207+ }
1208+
1209+ Instruction getArgumentDef ( ) { result = getAnOperand ( ) .( AddressOperand ) .getDef ( ) }
1210+
1211+ Instruction getSizeDef ( ) { result = getAnOperand ( ) .( BufferSizeOperand ) .getDef ( ) }
1212+ }
1213+
1214+ /**
1215+ * An instruction representing a side effect of a function call.
1216+ */
1217+ class WriteSideEffectInstruction extends SideEffectInstruction {
1218+ WriteSideEffectInstruction ( ) { getOpcode ( ) instanceof WriteSideEffectOpcode }
1219+
1220+ Instruction getArgumentDef ( ) { result = getAnOperand ( ) .( AddressOperand ) .getDef ( ) }
11851221}
11861222
11871223/**
11881224 * An instruction representing the write of an indirect parameter within a function call.
11891225 */
1190- class IndirectWriteSideEffectInstruction extends SideEffectInstruction {
1191- IndirectWriteSideEffectInstruction ( ) { getOpcode ( ) instanceof Opcode:: IndirectWriteSideEffect }
1226+ class IndirectMustWriteSideEffectInstruction extends WriteSideEffectInstruction {
1227+ IndirectMustWriteSideEffectInstruction ( ) {
1228+ getOpcode ( ) instanceof Opcode:: IndirectMustWriteSideEffect
1229+ }
11921230
11931231 final override MemoryAccessKind getResultMemoryAccess ( ) { result instanceof IndirectMemoryAccess }
11941232}
@@ -1197,18 +1235,34 @@ class IndirectWriteSideEffectInstruction extends SideEffectInstruction {
11971235 * An instruction representing the write of an indirect buffer parameter within a function call. The
11981236 * entire buffer is overwritten.
11991237 */
1200- class BufferWriteSideEffectInstruction extends SideEffectInstruction {
1201- BufferWriteSideEffectInstruction ( ) { getOpcode ( ) instanceof Opcode:: BufferWriteSideEffect }
1238+ class BufferMustWriteSideEffectInstruction extends WriteSideEffectInstruction {
1239+ BufferMustWriteSideEffectInstruction ( ) {
1240+ getOpcode ( ) instanceof Opcode:: BufferMustWriteSideEffect
1241+ }
12021242
12031243 final override MemoryAccessKind getResultMemoryAccess ( ) { result instanceof BufferMemoryAccess }
12041244}
12051245
1246+ /**
1247+ * An instruction representing the write of an indirect buffer parameter within a function call. The
1248+ * entire buffer is overwritten.
1249+ */
1250+ class SizedBufferMustWriteSideEffectInstruction extends WriteSideEffectInstruction {
1251+ SizedBufferMustWriteSideEffectInstruction ( ) {
1252+ getOpcode ( ) instanceof Opcode:: SizedBufferMustWriteSideEffect
1253+ }
1254+
1255+ final override MemoryAccessKind getResultMemoryAccess ( ) { result instanceof BufferMemoryAccess }
1256+
1257+ Instruction getSizeDef ( ) { result = getAnOperand ( ) .( BufferSizeOperand ) .getDef ( ) }
1258+ }
1259+
12061260/**
12071261 * An instruction representing the potential write of an indirect parameter within a function call.
12081262 * Unlike `IndirectWriteSideEffectInstruction`, the location might not be completely overwritten.
12091263 * written.
12101264 */
1211- class IndirectMayWriteSideEffectInstruction extends SideEffectInstruction {
1265+ class IndirectMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
12121266 IndirectMayWriteSideEffectInstruction ( ) {
12131267 getOpcode ( ) instanceof Opcode:: IndirectMayWriteSideEffect
12141268 }
@@ -1222,14 +1276,30 @@ class IndirectMayWriteSideEffectInstruction extends SideEffectInstruction {
12221276 * An instruction representing the write of an indirect buffer parameter within a function call.
12231277 * Unlike `BufferWriteSideEffectInstruction`, the buffer might not be completely overwritten.
12241278 */
1225- class BufferMayWriteSideEffectInstruction extends SideEffectInstruction {
1279+ class BufferMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
12261280 BufferMayWriteSideEffectInstruction ( ) { getOpcode ( ) instanceof Opcode:: BufferMayWriteSideEffect }
12271281
12281282 final override MemoryAccessKind getResultMemoryAccess ( ) {
12291283 result instanceof BufferMayMemoryAccess
12301284 }
12311285}
12321286
1287+ /**
1288+ * An instruction representing the write of an indirect buffer parameter within a function call.
1289+ * Unlike `BufferWriteSideEffectInstruction`, the buffer might not be completely overwritten.
1290+ */
1291+ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
1292+ SizedBufferMayWriteSideEffectInstruction ( ) {
1293+ getOpcode ( ) instanceof Opcode:: SizedBufferMayWriteSideEffect
1294+ }
1295+
1296+ final override MemoryAccessKind getResultMemoryAccess ( ) {
1297+ result instanceof BufferMayMemoryAccess
1298+ }
1299+
1300+ Instruction getSizeDef ( ) { result = getAnOperand ( ) .( BufferSizeOperand ) .getDef ( ) }
1301+ }
1302+
12331303/**
12341304 * An instruction representing a GNU or MSVC inline assembly statement.
12351305 */
0 commit comments