[llvm-commits] [llvm] r45120 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/Target/Target.td

Bill Wendling isanbard at gmail.com
Mon Dec 17 13:02:07 PST 2007


Author: void
Date: Mon Dec 17 15:02:07 2007
New Revision: 45120

URL: http://llvm.org/viewvc/llvm-project?rev=45120&view=rev
Log:
As per feedback, revised comments to (hopefully) make the different side effect
flags clearer.

Modified:
    llvm/trunk/include/llvm/Target/TargetInstrInfo.h
    llvm/trunk/lib/Target/Target.td

Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=45120&r1=45119&r2=45120&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Dec 17 15:02:07 2007
@@ -91,17 +91,23 @@
 // ARM instructions which can set condition code if 's' bit is set.
 const unsigned M_HAS_OPTIONAL_DEF      = 1 << 17;
 
-// M_MAY_HAVE_SIDE_EFFECTS - Set if this instruction *might* have side effects,
-// e.g. load instructions. Note: This and M_NEVER_HAS_SIDE_EFFECTS are mutually
-// exclusive. You can't set both! If neither flag is set, then the instruction
-// *always* has side effects.
-const unsigned M_MAY_HAVE_SIDE_EFFECTS = 1 << 18;
-
-// M_NEVER_HAS_SIDE_EFFECTS - Set if this instruction *never* has side effects,
-// e.g., xor on X86.  Note: This and M_MAY_HAVE_SIDE_EFFECTS are mutually
-// exclusive. You can't set both! If neither flag is set, then the instruction
-// *always* has side effects.
-const unsigned M_NEVER_HAS_SIDE_EFFECTS = 1 << 19;
+// M_NEVER_HAS_SIDE_EFFECTS - Set if this instruction has no side effects that
+// are not captured by any operands of the instruction or other flags, and when
+// *all* instances of the instruction of that opcode have no side effects.
+//
+// Note: This and M_MAY_HAVE_SIDE_EFFECTS are mutually exclusive. You can't set
+// both! If neither flag is set, then the instruction *always* has side effects.
+const unsigned M_NEVER_HAS_SIDE_EFFECTS = 1 << 18;
+
+// M_MAY_HAVE_SIDE_EFFECTS - Set if some instances of this instruction can have
+// side effects. The virtual method "isReallySideEffectFree" is called to
+// determine this. Load instructions are an example of where this is useful. In
+// general, loads always have side effects. However, loads from constant pools
+// don't. We let the specific back end make this determination.
+//
+// Note: This and M_NEVER_HAS_SIDE_EFFECTS are mutually exclusive. You can't set
+// both! If neither flag is set, then the instruction *always* has side effects.
+const unsigned M_MAY_HAVE_SIDE_EFFECTS = 1 << 19;
 
 // Machine operand flags
 // M_LOOK_UP_PTR_REG_CLASS - Set if this operand is a pointer value and it
@@ -321,6 +327,15 @@
     return true;
   }
 
+  /// isReallySideEffectFree - If the M_MAY_HAVE_SIDE_EFFECTS flag is set, this
+  /// method is called to determine if the specific instance of this
+  /// instructions has side effects. This is useful in cases of instructions,
+  /// like loads, which generally always have side effects. A load from a
+  /// constant pool doesn't have side effects, though. So we need to
+  /// differentiate it from the general case.
+  virtual bool isReallySideEffectFree(MachineInstr *MI) const {
+    return false;
+  }
 public:
   /// getOperandConstraint - Returns the value of the specific constraint if
   /// it is set. Returns -1 if it is not set.

Modified: llvm/trunk/lib/Target/Target.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Target.td?rev=45120&r1=45119&r2=45120&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Target.td (original)
+++ llvm/trunk/lib/Target/Target.td Mon Dec 17 15:02:07 2007
@@ -205,9 +205,18 @@
   bit isNotDuplicable = 0;  // Is it unsafe to duplicate this instruction?
 
   // Side effect flags - If neither of these flags is set, then the instruction
-  // *always* has side effects. Otherwise, it's one or the other.
-  bit mayHaveSideEffects = 0;  // This instruction *may* have side effects.
-  bit neverHasSideEffects = 0; // This instruction never has side effects.
+  // *always* has side effects. When set, the flags have these meanings:
+  //
+  //  neverHasSideEffects - The instruction has no side effects that are not
+  //    captured by any operands of the instruction or other flags, and when
+  //    *all* instances of the instruction of that opcode have no side effects.
+  //  mayHaveSideEffects  - Some instances of the instruction can have side
+  //    effects. The virtual method "isReallySideEffectFree" is called to
+  //    determine this. Load instructions are an example of where this is
+  //    useful. In general, loads always have side effects. However, loads from
+  //    constant pools don't. Individual back ends make this determination.
+  bit neverHasSideEffects = 0;
+  bit mayHaveSideEffects = 0;
   
   InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
 





More information about the llvm-commits mailing list