1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Add IntrInaccessibleMemOnly property for intrinsics

Differential Revision: https://reviews.llvm.org/D26485

llvm-svn: 287680
This commit is contained in:
Andrew Kaylor 2016-11-22 19:16:04 +00:00
parent 6069e88621
commit 4ae6506d2b
4 changed files with 69 additions and 7 deletions

View File

@ -43,6 +43,15 @@ def IntrWriteMem : IntrinsicProperty;
// reads from and (possibly volatile) writes to memory, it has no side effects.
def IntrArgMemOnly : IntrinsicProperty;
// IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
// accessible by the module being compiled. This is a weaker form of IntrNoMem.
def IntrInaccessibleMemOnly : IntrinsicProperty;
// IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
// its pointer-typed arguments point to or memory that is not accessible
// by the module being compiled. This is a weaker form of IntrArgMemOnly.
def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
// Commutative - This intrinsic is commutative: X op Y == Y op X.
def Commutative : IntrinsicProperty;

View File

@ -62,15 +62,23 @@ struct CodeGenIntrinsic {
/// accesses that may be performed by the intrinsics. Analogous to
/// \c FunctionModRefBehaviour.
enum ModRefBits {
/// The intrinsic may access memory that is otherwise inaccessible via
/// LLVM IR.
MR_InaccessibleMem = 1,
/// The intrinsic may access memory through pointer arguments.
/// LLVM IR.
MR_ArgMem = 2,
/// The intrinsic may access memory anywhere, i.e. it is not restricted
/// to access through pointer arguments.
MR_Anywhere = 1,
MR_Anywhere = 4 | MR_ArgMem | MR_InaccessibleMem,
/// The intrinsic may read memory.
MR_Ref = 2,
MR_Ref = 8,
/// The intrinsic may write memory.
MR_Mod = 4,
MR_Mod = 16,
/// The intrinsic may both read and write memory.
MR_ModRef = MR_Ref | MR_Mod,
@ -80,11 +88,18 @@ struct CodeGenIntrinsic {
/// properties (IntrReadMem, IntrArgMemOnly, etc.).
enum ModRefBehavior {
NoMem = 0,
ReadArgMem = MR_Ref,
ReadArgMem = MR_Ref | MR_ArgMem,
ReadInaccessibleMem = MR_Ref | MR_InaccessibleMem,
ReadInaccessibleMemOrArgMem = MR_Ref | MR_ArgMem | MR_InaccessibleMem,
ReadMem = MR_Ref | MR_Anywhere,
WriteArgMem = MR_Mod,
WriteArgMem = MR_Mod | MR_ArgMem,
WriteInaccessibleMem = MR_Mod | MR_InaccessibleMem,
WriteInaccessibleMemOrArgMem = MR_Mod | MR_ArgMem | MR_InaccessibleMem,
WriteMem = MR_Mod | MR_Anywhere,
ReadWriteArgMem = MR_ModRef,
ReadWriteArgMem = MR_ModRef | MR_ArgMem,
ReadWriteInaccessibleMem = MR_ModRef | MR_InaccessibleMem,
ReadWriteInaccessibleMemOrArgMem = MR_ModRef | MR_ArgMem |
MR_InaccessibleMem,
ReadWriteMem = MR_ModRef | MR_Anywhere,
};
ModRefBehavior ModRef;

View File

@ -593,7 +593,12 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
else if (Property->getName() == "IntrWriteMem")
ModRef = ModRefBehavior(ModRef & ~MR_Ref);
else if (Property->getName() == "IntrArgMemOnly")
ModRef = ModRefBehavior(ModRef & ~MR_Anywhere);
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem);
else if (Property->getName() == "IntrInaccessibleMemOnly")
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_InaccessibleMem);
else if (Property->getName() == "IntrInaccessibleMemOrArgMemOnly")
ModRef = ModRefBehavior((ModRef & ~MR_Anywhere) | MR_ArgMem |
MR_InaccessibleMem);
else if (Property->getName() == "Commutative")
isCommutative = true;
else if (Property->getName() == "Throws")

View File

@ -646,6 +646,18 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
OS << ",";
OS << "Attribute::ReadOnly";
break;
case CodeGenIntrinsic::ReadInaccessibleMem:
if (addComma)
OS << ",";
OS << "Attribute::ReadOnly,";
OS << "Attribute::InaccessibleMemOnly";
break;
case CodeGenIntrinsic::ReadInaccessibleMemOrArgMem:
if (addComma)
OS << ",";
OS << "Attribute::ReadOnly,";
OS << "Attribute::InaccessibleMemOrArgMemOnly";
break;
case CodeGenIntrinsic::WriteArgMem:
if (addComma)
OS << ",";
@ -657,11 +669,32 @@ void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
OS << ",";
OS << "Attribute::WriteOnly";
break;
case CodeGenIntrinsic::WriteInaccessibleMem:
if (addComma)
OS << ",";
OS << "Attribute::WriteOnly,";
OS << "Attribute::InaccessibleMemOnly";
break;
case CodeGenIntrinsic::WriteInaccessibleMemOrArgMem:
if (addComma)
OS << ",";
OS << "Attribute::WriteOnly,";
OS << "Attribute::InaccessibleMemOrArgOnly";
break;
case CodeGenIntrinsic::ReadWriteArgMem:
if (addComma)
OS << ",";
OS << "Attribute::ArgMemOnly";
break;
case CodeGenIntrinsic::ReadWriteInaccessibleMem:
if (addComma)
OS << ",";
OS << "Attribute::InaccessibleMemOnly";
break;
case CodeGenIntrinsic::ReadWriteInaccessibleMemOrArgMem:
if (addComma)
OS << ",";
OS << "Attribute::InaccessibleMemOrArgMemOnly";
case CodeGenIntrinsic::ReadWriteMem:
break;
}