[llvm-commits] [llvm] r167040 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h include/llvm/InlineAsm.h lib/CodeGen/MachineVerifier.cpp lib/CodeGen/ScheduleDAGInstrs.cpp lib/CodeGen/SelectionDAG/InstrEmitter.cpp lib/CodeGen/SelectionDAG/Sele

Eric Christopher echristo at gmail.com
Tue Oct 30 12:30:22 PDT 2012


LGTM, thanks for doing this!

One comment request:

+    if (OpInfo.ConstraintType == TargetLowering::C_Memory ||
+        OpInfo.ConstraintType == TargetLowering::C_Other) {

Can we get a comment on this?

-eric

On Tue, Oct 30, 2012 at 12:11 PM, Chad Rosier <mcrosier at apple.com> wrote:
> Author: mcrosier
> Date: Tue Oct 30 14:11:54 2012
> New Revision: 167040
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167040&view=rev
> Log:
> [inline asm] Implement mayLoad and mayStore for inline assembly.  In general,
> the MachineInstr MayLoad/MayLoad flags are based on the tablegen implementation.
> For inline assembly, however, we need to compute these based on the constraints.
>
> Revert r166929 as this is no longer needed, but leave the test case in place.
> rdar://12033048 and PR13504
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/MachineInstr.h
>     llvm/trunk/include/llvm/InlineAsm.h
>     llvm/trunk/lib/CodeGen/MachineVerifier.cpp
>     llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Tue Oct 30 14:11:54 2012
> @@ -58,8 +58,10 @@
>      NoFlags      = 0,
>      FrameSetup   = 1 << 0,              // Instruction is used as a part of
>                                          // function frame setup code.
> -    InsideBundle = 1 << 1               // Instruction is inside a bundle (not
> +    InsideBundle = 1 << 1,              // Instruction is inside a bundle (not
>                                          // the first MI in a bundle)
> +    MayLoad      = 1 << 2,              // Instruction could possibly read memory.
> +    MayStore     = 1 << 3               // Instruction could possibly modify memory.
>    };
>  private:
>    const MCInstrDesc *MCID;              // Instruction descriptor.
> @@ -445,7 +447,7 @@
>    /// Instructions with this flag set are not necessarily simple load
>    /// instructions, they may load a value and modify it, for example.
>    bool mayLoad(QueryType Type = AnyInBundle) const {
> -    return hasProperty(MCID::MayLoad, Type);
> +    return hasProperty(MCID::MayLoad, Type) || (Flags & MayLoad);
>    }
>
>
> @@ -454,7 +456,7 @@
>    /// instructions, they may store a modified value based on their operands, or
>    /// may not actually modify anything, for example.
>    bool mayStore(QueryType Type = AnyInBundle) const {
> -    return hasProperty(MCID::MayStore, Type);
> +    return hasProperty(MCID::MayStore, Type) || (Flags & MayStore);
>    }
>
>    //===--------------------------------------------------------------------===//
>
> Modified: llvm/trunk/include/llvm/InlineAsm.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InlineAsm.h?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/InlineAsm.h (original)
> +++ llvm/trunk/include/llvm/InlineAsm.h Tue Oct 30 14:11:54 2012
> @@ -214,6 +214,8 @@
>      Extra_HasSideEffects = 1,
>      Extra_IsAlignStack = 2,
>      Extra_AsmDialect = 4,
> +    Extra_MayLoad = 8,
> +    Extra_MayStore = 16,
>
>      // Inline asm operands map to multiple SDNode / MachineInstr operands.
>      // The first operand is an immediate describing the asm operand, the low
>
> Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Tue Oct 30 14:11:54 2012
> @@ -707,8 +707,9 @@
>      report("Asm string must be an external symbol", MI);
>    if (!MI->getOperand(1).isImm())
>      report("Asm flags must be an immediate", MI);
> -  // Allowed flags are Extra_HasSideEffects = 1, and Extra_IsAlignStack = 2.
> -  if (!isUInt<2>(MI->getOperand(1).getImm()))
> +  // Allowed flags are Extra_HasSideEffects = 1, Extra_IsAlignStack = 2,
> +  // Extra_AsmDialect = 4, Extra_MayLoad = 8, and Extra_MayStore = 16.
> +  if (!isUInt<5>(MI->getOperand(1).getImm()))
>      report("Unknown asm flags", &MI->getOperand(1), 1);
>
>    assert(InlineAsm::MIOp_FirstOperand == 2 && "Asm format changed");
>
> Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original)
> +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Tue Oct 30 14:11:54 2012
> @@ -420,11 +420,6 @@
>  /// Return true if MI is an instruction we are unable to reason about
>  /// (like a call or something with unmodeled side effects).
>  static inline bool isGlobalMemoryObject(AliasAnalysis *AA, MachineInstr *MI) {
> -  if (MI->isInlineAsm()) {
> -    // Until we can tell if an inline assembly instruction accesses
> -    // memory, we must assume all such instructions do so.
> -    return true;
> -  }
>    if (MI->isCall() || MI->hasUnmodeledSideEffects() ||
>        (MI->hasOrderedMemoryRef() &&
>         (!MI->mayLoad() || !MI->isInvariantLoad(AA))))
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Tue Oct 30 14:11:54 2012
> @@ -903,6 +903,13 @@
>                            getZExtValue();
>      MI->addOperand(MachineOperand::CreateImm(ExtraInfo));
>
> +    // Set the MayLoad and MayStore flags.
> +    if (ExtraInfo & InlineAsm::Extra_MayLoad)
> +      MI->setFlag(MachineInstr::MayLoad);
> +
> +    if (ExtraInfo & InlineAsm::Extra_MayStore)
> +      MI->setFlag(MachineInstr::MayStore);
> +
>      // Remember to operand index of the group flags.
>      SmallVector<unsigned, 8> GroupIdx;
>
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=167040&r1=167039&r2=167040&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Oct 30 14:11:54 2012
> @@ -6128,7 +6128,8 @@
>    const MDNode *SrcLoc = CS.getInstruction()->getMetadata("srcloc");
>    AsmNodeOperands.push_back(DAG.getMDNode(SrcLoc));
>
> -  // Remember the HasSideEffect, AlignStack and AsmDialect bits as operand 3.
> +  // Remember the HasSideEffect, AlignStack, AsmDialect, MayLoad and MayStore
> +  // bits as operand 3.
>    unsigned ExtraInfo = 0;
>    if (IA->hasSideEffects())
>      ExtraInfo |= InlineAsm::Extra_HasSideEffects;
> @@ -6136,6 +6137,23 @@
>      ExtraInfo |= InlineAsm::Extra_IsAlignStack;
>    // Set the asm dialect.
>    ExtraInfo |= IA->getDialect() * InlineAsm::Extra_AsmDialect;
> +
> +  // Determine if this InlineAsm MayLoad or MayStore based on the constraints.
> +  for (unsigned i = 0, e = TargetConstraints.size(); i != e; ++i) {
> +    TargetLowering::AsmOperandInfo &OpInfo = TargetConstraints[i];
> +
> +    // Compute the constraint code and ConstraintType to use.
> +    TLI.ComputeConstraintToUse(OpInfo, SDValue());
> +
> +    if (OpInfo.ConstraintType == TargetLowering::C_Memory ||
> +        OpInfo.ConstraintType == TargetLowering::C_Other) {
> +      if (OpInfo.Type == InlineAsm::isInput)
> +        ExtraInfo |= InlineAsm::Extra_MayLoad;
> +      else if (OpInfo.Type == InlineAsm::isOutput)
> +        ExtraInfo |= InlineAsm::Extra_MayStore;
> +    }
> +  }
> +
>    AsmNodeOperands.push_back(DAG.getTargetConstant(ExtraInfo,
>                                                    TLI.getPointerTy()));
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list