From baldrick at free.fr Mon Jul 25 02:56:56 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 07:56:56 -0000
Subject: [llvm-commits] [dragonegg] r135900 -
/dragonegg/trunk/src/Backend.cpp
Message-ID: <20110725075656.4100E2A6C12F@llvm.org>
Author: baldrick
Date: Mon Jul 25 02:56:56 2011
New Revision: 135900
URL: http://llvm.org/viewvc/llvm-project?rev=135900&view=rev
Log:
Port commits 135235 and 135814 (evancheng) from llvm-gcc. Original
changelog entries:
Initialize MCAsmInfo.
Match LLVM API change.
Modified:
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=135900&r1=135899&r2=135900&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Mon Jul 25 02:56:56 2011
@@ -268,6 +268,7 @@
#define Declare(T, M) Declare2(T, M)
Declare(LLVM_TARGET_NAME, TargetInfo);
Declare(LLVM_TARGET_NAME, Target);
+ Declare(LLVM_TARGET_NAME, TargetMC);
Declare(LLVM_TARGET_NAME, AsmPrinter);
#undef Declare
#undef Declare2
@@ -280,6 +281,7 @@
#define DoInit(T, M) DoInit2(T, M)
DoInit(LLVM_TARGET_NAME, TargetInfo);
DoInit(LLVM_TARGET_NAME, Target);
+ DoInit(LLVM_TARGET_NAME, TargetMC);
DoInit(LLVM_TARGET_NAME, AsmPrinter);
#undef DoInit
#undef DoInit2
From baldrick at free.fr Mon Jul 25 03:25:12 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 08:25:12 -0000
Subject: [llvm-commits] [dragonegg] r135901 - in /dragonegg/trunk:
include/darwin/dragonegg/OS.h include/freebsd/dragonegg/OS.h
include/linux/dragonegg/OS.h include/openbsd/dragonegg/OS.h src/Backend.cpp
Message-ID: <20110725082512.2B8E22A6C12C@llvm.org>
Author: baldrick
Date: Mon Jul 25 03:25:11 2011
New Revision: 135901
URL: http://llvm.org/viewvc/llvm-project?rev=135901&view=rev
Log:
Port commit 135470 (evancheng) from llvm-gcc. Original changelog entry:
Match createTargetMachine API change.
Modified:
dragonegg/trunk/include/darwin/dragonegg/OS.h
dragonegg/trunk/include/freebsd/dragonegg/OS.h
dragonegg/trunk/include/linux/dragonegg/OS.h
dragonegg/trunk/include/openbsd/dragonegg/OS.h
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/include/darwin/dragonegg/OS.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/darwin/dragonegg/OS.h?rev=135901&r1=135900&r2=135901&view=diff
==============================================================================
--- dragonegg/trunk/include/darwin/dragonegg/OS.h (original)
+++ dragonegg/trunk/include/darwin/dragonegg/OS.h Mon Jul 25 03:25:11 2011
@@ -25,23 +25,23 @@
/* Darwin X86-64 only supports PIC code generation. */
#if defined (TARGET_386)
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if ((TARGET_64BIT) || flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else if (!MACHO_DYNAMIC_NO_PIC_P) \
- argvec.push_back ("--relocation-model=static")
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if ((TARGET_64BIT) || flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else if (!MACHO_DYNAMIC_NO_PIC_P) \
+ RelocModel = Reloc::Static;
#elif defined (TARGET_ARM)
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if (flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else if (!MACHO_DYNAMIC_NO_PIC_P) \
- argvec.push_back ("--relocation-model=static"); \
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if (flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else if (!MACHO_DYNAMIC_NO_PIC_P) \
+ RelocModel = Reloc::Static; \
#else /* !TARGET_386 && !TARGET_ARM */
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if (flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else if (!MACHO_DYNAMIC_NO_PIC_P) \
- argvec.push_back ("--relocation-model=static")
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if (flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else if (!MACHO_DYNAMIC_NO_PIC_P) \
+ RelocModel = Reloc::Static;
#endif /* !TARGET_386 && !TARGET_ARM */
/* Give a constant string a sufficient alignment for the platform. */
Modified: dragonegg/trunk/include/freebsd/dragonegg/OS.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/freebsd/dragonegg/OS.h?rev=135901&r1=135900&r2=135901&view=diff
==============================================================================
--- dragonegg/trunk/include/freebsd/dragonegg/OS.h (original)
+++ dragonegg/trunk/include/freebsd/dragonegg/OS.h Mon Jul 25 03:25:11 2011
@@ -24,10 +24,10 @@
#define DRAGONEGG_OS_H
/* Yes, we support PIC codegen for FreeBSD targets! */
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if (flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else \
- argvec.push_back ("--relocation-model=static");
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if (flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else \
+ RelocModel = Reloc::Static;
#endif /* DRAGONEGG_OS_H */
Modified: dragonegg/trunk/include/linux/dragonegg/OS.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/linux/dragonegg/OS.h?rev=135901&r1=135900&r2=135901&view=diff
==============================================================================
--- dragonegg/trunk/include/linux/dragonegg/OS.h (original)
+++ dragonegg/trunk/include/linux/dragonegg/OS.h Mon Jul 25 03:25:11 2011
@@ -24,10 +24,10 @@
#define DRAGONEGG_OS_H
/* Yes, we support PIC codegen for linux targets! */
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if (flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else \
- argvec.push_back ("--relocation-model=static");
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if (flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else \
+ RelocModel = Reloc::Static;
#endif /* DRAGONEGG_OS_H */
Modified: dragonegg/trunk/include/openbsd/dragonegg/OS.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/openbsd/dragonegg/OS.h?rev=135901&r1=135900&r2=135901&view=diff
==============================================================================
--- dragonegg/trunk/include/openbsd/dragonegg/OS.h (original)
+++ dragonegg/trunk/include/openbsd/dragonegg/OS.h Mon Jul 25 03:25:11 2011
@@ -24,10 +24,10 @@
#define DRAGONEGG_OS_H
/* Yes, we support PIC codegen for OpenBSD targets! */
-#define LLVM_SET_TARGET_OPTIONS(argvec) \
- if (flag_pic) \
- argvec.push_back ("--relocation-model=pic"); \
- else \
- argvec.push_back ("--relocation-model=static");
+#define LLVM_SET_RELOC_MODEL(RelocModel) \
+ if (flag_pic) \
+ RelocModel = Reloc::PIC_; \
+ else \
+ RelocModel = Reloc::Static;
#endif /* DRAGONEGG_OS_H */
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=135901&r1=135900&r2=135901&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Mon Jul 25 03:25:11 2011
@@ -39,6 +39,7 @@
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
+#include "llvm/MC/MCCodeGenInfo.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PassManagerBuilder.h"
@@ -413,7 +414,15 @@
LLVM_SET_SUBTARGET_FEATURES(CPU, Features);
FeatureStr = Features.getString();
#endif
- TheTarget = TME->createTargetMachine(TargetTriple, CPU, FeatureStr);
+
+ // The target can set LLVM_SET_RELOC_MODEL to configure the relocation
+ // model used by the LLVM backend.
+ Reloc::Model RelocModel = Reloc::Default;
+#ifdef LLVM_SET_RELOC_MODEL
+ LLVM_SET_RELOC_MODEL(RelocModel);
+#endif
+ TheTarget = TME->createTargetMachine(TargetTriple, CPU, FeatureStr,
+ RelocModel);
TheTarget->setMCUseCFI(flag_dwarf2_cfi_asm);
assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN);
}
From baldrick at free.fr Mon Jul 25 03:30:44 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 08:30:44 -0000
Subject: [llvm-commits] [dragonegg] r135902 - /dragonegg/trunk/src/Debug.cpp
Message-ID: <20110725083044.8A23D2A6C12C@llvm.org>
Author: baldrick
Date: Mon Jul 25 03:30:44 2011
New Revision: 135902
URL: http://llvm.org/viewvc/llvm-project?rev=135902&view=rev
Log:
Port commit 135505 (dpatel) from llvm-gcc. Original changelog entry:
Update DebugFactory to match r135504.
Modified:
dragonegg/trunk/src/Debug.cpp
Modified: dragonegg/trunk/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=135902&r1=135901&r2=135902&view=diff
==============================================================================
--- dragonegg/trunk/src/Debug.cpp (original)
+++ dragonegg/trunk/src/Debug.cpp Mon Jul 25 03:30:44 2011
@@ -1645,7 +1645,8 @@
F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Ty,
- ConstantInt::get(Type::getInt32Ty(VMContext), Flags)
+ ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
+ Constant::getNullValue(Type::getInt32Ty(VMContext))
};
MDNode *Node = MDNode::get(VMContext, Elts);
if (AlwaysPreserve) {
@@ -1682,6 +1683,8 @@
Elts.push_back(F);
Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo));
Elts.push_back(Ty);
+ Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
+ Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
Elts.append(Addr, Addr+NumAddr);
return DIVariable(MDNode::get(VMContext, Elts));
From baldrick at free.fr Mon Jul 25 03:49:56 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 08:49:56 -0000
Subject: [llvm-commits] [dragonegg] r135903 - in /dragonegg/trunk:
include/x86/dragonegg/Target.h src/Backend.cpp
Message-ID: <20110725084956.373512A6C12C@llvm.org>
Author: baldrick
Date: Mon Jul 25 03:49:56 2011
New Revision: 135903
URL: http://llvm.org/viewvc/llvm-project?rev=135903&view=rev
Log:
Port commits 135588 (evancheng), 135589 (evancheng) and 135618 (efriedma)
from llvm-gcc. Original changelog entries:
Unbreak llvm-c build.
CM_32 means default code mode.
Attempt to unbreak llvm-gcc.
Modified:
dragonegg/trunk/include/x86/dragonegg/Target.h
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/include/x86/dragonegg/Target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/x86/dragonegg/Target.h?rev=135903&r1=135902&r2=135903&view=diff
==============================================================================
--- dragonegg/trunk/include/x86/dragonegg/Target.h (original)
+++ dragonegg/trunk/include/x86/dragonegg/Target.h Mon Jul 25 03:49:56 2011
@@ -371,33 +371,39 @@
#define LLVM_CANONICAL_ADDRESS_CONSTRAINTS "im"
/* Propagate code model setting to backend */
-#define LLVM_SET_MACHINE_OPTIONS(argvec) \
- do { \
- switch (ix86_cmodel) { \
- default: \
- sorry ("code model %<%s%> not supported yet", \
- ix86_cmodel_string); \
- break; \
- case CM_SMALL: \
- case CM_SMALL_PIC: \
- argvec.push_back("--code-model=small"); \
- break; \
- case CM_KERNEL: \
- argvec.push_back("--code-model=kernel"); \
- break; \
- case CM_MEDIUM: \
- case CM_MEDIUM_PIC: \
- argvec.push_back("--code-model=medium"); \
- break; \
- case CM_32: \
- argvec.push_back("--code-model=default"); \
- break; \
- } \
- if (TARGET_OMIT_LEAF_FRAME_POINTER) \
- argvec.push_back("--disable-non-leaf-fp-elim"); \
- \
- if (ix86_force_align_arg_pointer) \
- argvec.push_back("-force-align-stack"); \
+#define LLVM_SET_CODE_MODEL(CMModel) \
+ switch (ix86_cmodel) { \
+ default: \
+ sorry ("code model %<%s%> not supported yet", \
+ ix86_cmodel_string); \
+ break; \
+ case CM_32: \
+ CMModel = CodeModel::Default; \
+ break; \
+ case CM_SMALL: \
+ case CM_SMALL_PIC: \
+ CMModel = CodeModel::Small; \
+ break; \
+ case CM_KERNEL: \
+ CMModel = CodeModel::Kernel; \
+ break; \
+ case CM_MEDIUM: \
+ case CM_MEDIUM_PIC: \
+ CMModel = CodeModel::Medium; \
+ break; \
+ case CM_LARGE: \
+ case CM_LARGE_PIC: \
+ CMModel = CodeModel::Large; \
+ break; \
+ }
+
+#define LLVM_SET_MACHINE_OPTIONS(argvec) \
+ do { \
+ if (TARGET_OMIT_LEAF_FRAME_POINTER) \
+ argvec.push_back("--disable-non-leaf-fp-elim"); \
+ \
+ if (ix86_force_align_arg_pointer) \
+ argvec.push_back("-force-align-stack"); \
} while (0)
#endif /* DRAGONEGG_TARGET_H */
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=135903&r1=135902&r2=135903&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Mon Jul 25 03:49:56 2011
@@ -415,14 +415,22 @@
FeatureStr = Features.getString();
#endif
- // The target can set LLVM_SET_RELOC_MODEL to configure the relocation
- // model used by the LLVM backend.
+ // The target can set LLVM_SET_RELOC_MODEL to configure the relocation model
+ // used by the LLVM backend.
Reloc::Model RelocModel = Reloc::Default;
#ifdef LLVM_SET_RELOC_MODEL
LLVM_SET_RELOC_MODEL(RelocModel);
#endif
+
+ // The target can set LLVM_SET_CODE_MODEL to configure the code model used
+ // used by the LLVM backend.
+ CodeModel::Model CMModel = CodeModel::Default;
+#ifdef LLVM_SET_CODE_MODEL
+ LLVM_SET_CODE_MODEL(CMModel);
+#endif
+
TheTarget = TME->createTargetMachine(TargetTriple, CPU, FeatureStr,
- RelocModel);
+ RelocModel, CMModel);
TheTarget->setMCUseCFI(flag_dwarf2_cfi_asm);
assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN);
}
From baldrick at free.fr Mon Jul 25 03:58:59 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 10:58:59 +0200
Subject: [llvm-commits] [llvm-gcc-4.2] r134830 - in
/llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386.cpp llvm-backend.cpp
llvm-convert.cpp llvm-internal.h llvm-linker-hack.cpp llvm-types.cpp
In-Reply-To: <6C807505-3D89-4D8A-BE78-312737C0A76D@apple.com>
References: <20110709174147.53C2E2A6C12C@llvm.org> <4E2C4BEF.3000503@free.fr>
<6C807505-3D89-4D8A-BE78-312737C0A76D@apple.com>
Message-ID: <4E2D3053.6000403@free.fr>
Hi Chris,
...
>> do you remember what this is about? Do you have a testcase?
>
> I don't have a testcase. IIRC, the ObjC frontend was making metadata whose initializer had a different type than the global variable backing it.
I think it must have been more complicated than that, since that case should
already be handled. Probably the dragonegg testsuite will allow me to reproduce
the problem if it still exists. If it doesn't I don't care enough about ObjC
to do anything more :)
Ciao, Duncan.
From baldrick at free.fr Mon Jul 25 03:59:39 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 10:59:39 +0200
Subject: [llvm-commits] Fwd: [llvm-gcc-4.2] r135505 -
/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
In-Reply-To: <01EF41C1-2E50-4202-A042-02AE98E12CE8@apple.com>
References: <20110719194214.CB8E92A6C12D@llvm.org>
<01EF41C1-2E50-4202-A042-02AE98E12CE8@apple.com>
Message-ID: <4E2D307B.2050802@free.fr>
Hi Devang,
> Please apply this patch to dragon-egg also. This is required to match
> corresponding change in llvm.
I did, thanks!
Ciao, Duncan.
From jay.foad at gmail.com Mon Jul 25 04:48:08 2011
From: jay.foad at gmail.com (Jay Foad)
Date: Mon, 25 Jul 2011 09:48:08 -0000
Subject: [llvm-commits] [llvm] r135904 - in /llvm/trunk: docs/ include/llvm/
include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/
lib/CodeGen/ lib/Transforms/IPO/ lib/Transforms/InstCombine/
lib/Transforms/Instrumentation/ lib/Transforms/Scalar/
lib/Transforms/Utils/ lib/VMCore/ unittests/Transforms/Utils/
Message-ID: <20110725094809.6199A2A6C12C@llvm.org>
Author: foad
Date: Mon Jul 25 04:48:08 2011
New Revision: 135904
URL: http://llvm.org/viewvc/llvm-project?rev=135904&view=rev
Log:
Convert GetElementPtrInst to use ArrayRef.
Modified:
llvm/trunk/docs/ReleaseNotes.html
llvm/trunk/include/llvm/Instructions.h
llvm/trunk/include/llvm/Support/IRBuilder.h
llvm/trunk/include/llvm/Support/NoFolder.h
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/PHITransAddr.cpp
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Instrumentation/PathProfiling.cpp
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
llvm/trunk/lib/VMCore/ConstantFold.cpp
llvm/trunk/lib/VMCore/Constants.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
llvm/trunk/lib/VMCore/Verifier.cpp
llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
Modified: llvm/trunk/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/docs/ReleaseNotes.html (original)
+++ llvm/trunk/docs/ReleaseNotes.html Mon Jul 25 04:48:08 2011
@@ -639,6 +639,9 @@
FindInsertedValue (in llvm/Analysis/ValueTracking.h)
gep_type_begin (in llvm/Support/GetElementPtrTypeIterator.h)
gep_type_end (in llvm/Support/GetElementPtrTypeIterator.h)
+GetElementPtrInst::Create
+GetElementPtrInst::CreateInBounds
+GetElementPtrInst::getIndexedType
InsertValueInst::Create
InsertValueInst::getIndices
InvokeInst::Create
Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Mon Jul 25 04:48:08 2011
@@ -285,149 +285,51 @@
///
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI);
- void init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
- const Twine &NameStr);
- void init(Value *Ptr, Value *Idx, const Twine &NameStr);
-
- template
- void init(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
- const Twine &NameStr,
- // This argument ensures that we have an iterator we can
- // do arithmetic on in constant time
- std::random_access_iterator_tag) {
- unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd));
-
- if (NumIdx > 0) {
- // This requires that the iterator points to contiguous memory.
- init(Ptr, &*IdxBegin, NumIdx, NameStr); // FIXME: for the general case
- // we have to build an array here
- }
- else {
- init(Ptr, 0, NumIdx, NameStr);
- }
- }
-
- /// getIndexedType - Returns the type of the element that would be loaded with
- /// a load instruction with the specified parameters.
- ///
- /// Null is returned if the indices are invalid for the specified
- /// pointer type.
- ///
- template
- static Type *getIndexedType(Type *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
- // This argument ensures that we
- // have an iterator we can do
- // arithmetic on in constant time
- std::random_access_iterator_tag) {
- unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd));
-
- if (NumIdx > 0)
- // This requires that the iterator points to contiguous memory.
- return getIndexedType(Ptr, &*IdxBegin, NumIdx);
- else
- return getIndexedType(Ptr, (Value *const*)0, NumIdx);
- }
+ void init(Value *Ptr, ArrayRef IdxList, const Twine &NameStr);
/// Constructors - Create a getelementptr instruction with a base pointer an
/// list of indices. The first ctor can optionally insert before an existing
/// instruction, the second appends the new instruction to the specified
/// BasicBlock.
- template
- inline GetElementPtrInst(Value *Ptr, RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
- unsigned Values,
- const Twine &NameStr,
+ inline GetElementPtrInst(Value *Ptr, ArrayRef IdxList,
+ unsigned Values, const Twine &NameStr,
Instruction *InsertBefore);
- template
- inline GetElementPtrInst(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
- unsigned Values,
- const Twine &NameStr, BasicBlock *InsertAtEnd);
-
- /// Constructors - These two constructors are convenience methods because one
- /// and two index getelementptr instructions are so common.
- GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &NameStr = "",
- Instruction *InsertBefore = 0);
- GetElementPtrInst(Value *Ptr, Value *Idx,
- const Twine &NameStr, BasicBlock *InsertAtEnd);
+ inline GetElementPtrInst(Value *Ptr, ArrayRef IdxList,
+ unsigned Values, const Twine &NameStr,
+ BasicBlock *InsertAtEnd);
protected:
virtual GetElementPtrInst *clone_impl() const;
public:
- template
- static GetElementPtrInst *Create(Value *Ptr, RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ static GetElementPtrInst *Create(Value *Ptr, ArrayRef IdxList,
const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
- typename std::iterator_traits::difference_type
- Values = 1 + std::distance(IdxBegin, IdxEnd);
+ unsigned Values = 1 + unsigned(IdxList.size());
return new(Values)
- GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, NameStr, InsertBefore);
+ GetElementPtrInst(Ptr, IdxList, Values, NameStr, InsertBefore);
}
- template
- static GetElementPtrInst *Create(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ static GetElementPtrInst *Create(Value *Ptr, ArrayRef IdxList,
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
- typename std::iterator_traits::difference_type
- Values = 1 + std::distance(IdxBegin, IdxEnd);
+ unsigned Values = 1 + unsigned(IdxList.size());
return new(Values)
- GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, NameStr, InsertAtEnd);
- }
-
- /// Constructors - These two creators are convenience methods because one
- /// index getelementptr instructions are so common.
- static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const Twine &NameStr = "",
- Instruction *InsertBefore = 0) {
- return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertBefore);
- }
- static GetElementPtrInst *Create(Value *Ptr, Value *Idx,
- const Twine &NameStr,
- BasicBlock *InsertAtEnd) {
- return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
+ GetElementPtrInst(Ptr, IdxList, Values, NameStr, InsertAtEnd);
}
/// Create an "inbounds" getelementptr. See the documentation for the
/// "inbounds" flag in LangRef.html for details.
- template
static GetElementPtrInst *CreateInBounds(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef IdxList,
const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
- GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd,
- NameStr, InsertBefore);
+ GetElementPtrInst *GEP = Create(Ptr, IdxList, NameStr, InsertBefore);
GEP->setIsInBounds(true);
return GEP;
}
- template
static GetElementPtrInst *CreateInBounds(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
- const Twine &NameStr,
- BasicBlock *InsertAtEnd) {
- GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd,
- NameStr, InsertAtEnd);
- GEP->setIsInBounds(true);
- return GEP;
- }
- static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx,
- const Twine &NameStr = "",
- Instruction *InsertBefore = 0) {
- GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertBefore);
- GEP->setIsInBounds(true);
- return GEP;
- }
- static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx,
+ ArrayRef IdxList,
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
- GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertAtEnd);
+ GetElementPtrInst *GEP = Create(Ptr, IdxList, NameStr, InsertAtEnd);
GEP->setIsInBounds(true);
return GEP;
}
@@ -446,23 +348,9 @@
/// Null is returned if the indices are invalid for the specified
/// pointer type.
///
- template
- static Type *getIndexedType(Type *Ptr, RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd) {
- return getIndexedType(Ptr, IdxBegin, IdxEnd,
- typename std::iterator_traits::
- iterator_category());
- }
-
- // FIXME: Use ArrayRef
- static Type *getIndexedType(Type *Ptr,
- Value* const *Idx, unsigned NumIdx);
- static Type *getIndexedType(Type *Ptr,
- Constant* const *Idx, unsigned NumIdx);
-
- static Type *getIndexedType(Type *Ptr,
- uint64_t const *Idx, unsigned NumIdx);
- static Type *getIndexedType(Type *Ptr, Value *Idx);
+ static Type *getIndexedType(Type *Ptr, ArrayRef IdxList);
+ static Type *getIndexedType(Type *Ptr, ArrayRef IdxList);
+ static Type *getIndexedType(Type *Ptr, ArrayRef IdxList);
inline op_iterator idx_begin() { return op_begin()+1; }
inline const_op_iterator idx_begin() const { return op_begin()+1; }
@@ -530,43 +418,33 @@
public VariadicOperandTraits {
};
-template
GetElementPtrInst::GetElementPtrInst(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef IdxList,
unsigned Values,
const Twine &NameStr,
Instruction *InsertBefore)
: Instruction(PointerType::get(checkGEPType(
- getIndexedType(Ptr->getType(),
- IdxBegin, IdxEnd)),
+ getIndexedType(Ptr->getType(), IdxList)),
cast(Ptr->getType())
->getAddressSpace()),
GetElementPtr,
OperandTraits::op_end(this) - Values,
Values, InsertBefore) {
- init(Ptr, IdxBegin, IdxEnd, NameStr,
- typename std::iterator_traits
- ::iterator_category());
+ init(Ptr, IdxList, NameStr);
}
-template
GetElementPtrInst::GetElementPtrInst(Value *Ptr,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef IdxList,
unsigned Values,
const Twine &NameStr,
BasicBlock *InsertAtEnd)
: Instruction(PointerType::get(checkGEPType(
- getIndexedType(Ptr->getType(),
- IdxBegin, IdxEnd)),
+ getIndexedType(Ptr->getType(), IdxList)),
cast(Ptr->getType())
->getAddressSpace()),
GetElementPtr,
OperandTraits::op_end(this) - Values,
Values, InsertAtEnd) {
- init(Ptr, IdxBegin, IdxEnd, NameStr,
- typename std::iterator_traits
- ::iterator_category());
+ init(Ptr, IdxList, NameStr);
}
Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Jul 25 04:48:08 2011
@@ -773,9 +773,7 @@
if (i == e)
return Insert(Folder.CreateGetElementPtr(PC, IdxList), Name);
}
- return Insert(GetElementPtrInst::Create(Ptr, IdxList.begin(),
- IdxList.end()),
- Name);
+ return Insert(GetElementPtrInst::Create(Ptr, IdxList), Name);
}
Value *CreateInBoundsGEP(Value *Ptr, ArrayRef IdxList,
const Twine &Name = "") {
@@ -788,9 +786,7 @@
if (i == e)
return Insert(Folder.CreateInBoundsGetElementPtr(PC, IdxList), Name);
}
- return Insert(GetElementPtrInst::CreateInBounds(Ptr, IdxList.begin(),
- IdxList.end()),
- Name);
+ return Insert(GetElementPtrInst::CreateInBounds(Ptr, IdxList), Name);
}
Value *CreateGEP(Value *Ptr, Value *Idx, const Twine &Name = "") {
if (Constant *PC = dyn_cast(Ptr))
@@ -831,7 +827,7 @@
if (Constant *PC = dyn_cast(Ptr))
return Insert(Folder.CreateGetElementPtr(PC, Idxs), Name);
- return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);
+ return Insert(GetElementPtrInst::Create(Ptr, Idxs), Name);
}
Value *CreateConstInBoundsGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1,
const Twine &Name = "") {
@@ -843,7 +839,7 @@
if (Constant *PC = dyn_cast(Ptr))
return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idxs), Name);
- return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idxs, Idxs+2), Name);
+ return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idxs), Name);
}
Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const Twine &Name = "") {
Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
@@ -872,7 +868,7 @@
if (Constant *PC = dyn_cast(Ptr))
return Insert(Folder.CreateGetElementPtr(PC, Idxs), Name);
- return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);
+ return Insert(GetElementPtrInst::Create(Ptr, Idxs), Name);
}
Value *CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1,
const Twine &Name = "") {
@@ -884,7 +880,7 @@
if (Constant *PC = dyn_cast(Ptr))
return Insert(Folder.CreateInBoundsGetElementPtr(PC, Idxs), Name);
- return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idxs, Idxs+2), Name);
+ return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idxs), Name);
}
Value *CreateStructGEP(Value *Ptr, unsigned Idx, const Twine &Name = "") {
return CreateConstInBoundsGEP2_32(Ptr, 0, Idx, Name);
Modified: llvm/trunk/include/llvm/Support/NoFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NoFolder.h?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/NoFolder.h (original)
+++ llvm/trunk/include/llvm/Support/NoFolder.h Mon Jul 25 04:48:08 2011
@@ -183,7 +183,7 @@
}
Instruction *CreateGetElementPtr(Constant *C,
ArrayRef IdxList) const {
- return GetElementPtrInst::Create(C, IdxList.begin(), IdxList.end());
+ return GetElementPtrInst::Create(C, IdxList);
}
Constant *CreateInBoundsGetElementPtr(Constant *C,
@@ -192,7 +192,7 @@
}
Instruction *CreateInBoundsGetElementPtr(Constant *C,
ArrayRef IdxList) const {
- return GetElementPtrInst::CreateInBounds(C, IdxList.begin(), IdxList.end());
+ return GetElementPtrInst::CreateInBounds(C, IdxList);
}
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Jul 25 04:48:08 2011
@@ -547,8 +547,7 @@
for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
if ((i == 1 ||
!isa(GetElementPtrInst::getIndexedType(Ops[0]->getType(),
- Ops.data() + 1,
- i-1))) &&
+ Ops.slice(1, i-1)))) &&
Ops[i]->getType() != IntPtrTy) {
Any = true;
NewIdxs.push_back(ConstantExpr::getCast(CastInst::getCastOpcode(Ops[i],
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Jul 25 04:48:08 2011
@@ -2230,8 +2230,7 @@
if (isa(Ops[0])) {
// Compute the (pointer) type returned by the GEP instruction.
- Type *LastType = GetElementPtrInst::getIndexedType(PtrTy, Ops.data() + 1,
- Ops.size() - 1);
+ Type *LastType = GetElementPtrInst::getIndexedType(PtrTy, Ops.slice(1));
Type *GEPTy = PointerType::get(LastType, PtrTy->getAddressSpace());
return UndefValue::get(GEPTy);
}
Modified: llvm/trunk/lib/Analysis/PHITransAddr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PHITransAddr.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/PHITransAddr.cpp (original)
+++ llvm/trunk/lib/Analysis/PHITransAddr.cpp Mon Jul 25 04:48:08 2011
@@ -407,9 +407,10 @@
}
GetElementPtrInst *Result =
- GetElementPtrInst::Create(GEPOps[0], GEPOps.begin()+1, GEPOps.end(),
- InVal->getName()+".phi.trans.insert",
- PredBB->getTerminator());
+ GetElementPtrInst::Create(GEPOps[0],
+ makeArrayRef(GEPOps.begin() + 1, GEPOps.end()),
+ InVal->getName()+".phi.trans.insert",
+ PredBB->getTerminator());
Result->setIsInBounds(GEP->isInBounds());
NewInsts.push_back(Result);
return Result;
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 25 04:48:08 2011
@@ -2274,9 +2274,7 @@
return Error(ID.Loc, "getelementptr requires pointer operand");
ArrayRef Indices(Elts.begin() + 1, Elts.end());
- if (!GetElementPtrInst::getIndexedType(Elts[0]->getType(),
- (Value**)(Elts.data() + 1),
- Elts.size() - 1))
+ if (!GetElementPtrInst::getIndexedType(Elts[0]->getType(), Indices))
return Error(ID.Loc, "invalid indices for getelementptr");
ID.ConstantVal = ConstantExpr::getGetElementPtr(Elts[0], Indices,
InBounds);
@@ -3660,10 +3658,9 @@
Indices.push_back(Val);
}
- if (!GetElementPtrInst::getIndexedType(Ptr->getType(),
- Indices.begin(), Indices.end()))
+ if (!GetElementPtrInst::getIndexedType(Ptr->getType(), Indices))
return Error(Loc, "invalid getelementptr indices");
- Inst = GetElementPtrInst::Create(Ptr, Indices.begin(), Indices.end());
+ Inst = GetElementPtrInst::Create(Ptr, Indices);
if (InBounds)
cast(Inst)->setIsInBounds(true);
return AteExtraComma ? InstExtraComma : InstNormal;
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 25 04:48:08 2011
@@ -2181,7 +2181,7 @@
GEPIdx.push_back(Op);
}
- I = GetElementPtrInst::Create(BasePtr, GEPIdx.begin(), GEPIdx.end());
+ I = GetElementPtrInst::Create(BasePtr, GEPIdx);
InstructionList.push_back(I);
if (BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP)
cast(I)->setIsInBounds(true);
Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Jul 25 04:48:08 2011
@@ -386,22 +386,20 @@
// We need to also keep around a reference to the call_site field
Idxs[0] = Zero;
Idxs[1] = ConstantInt::get(Int32Ty, 1);
- CallSite = GetElementPtrInst::Create(FunctionContext, Idxs, Idxs+2,
- "call_site",
+ CallSite = GetElementPtrInst::Create(FunctionContext, Idxs, "call_site",
EntryBB->getTerminator());
// The exception selector comes back in context->data[1]
Idxs[1] = ConstantInt::get(Int32Ty, 2);
- Value *FCData = GetElementPtrInst::Create(FunctionContext, Idxs, Idxs+2,
- "fc_data",
+ Value *FCData = GetElementPtrInst::Create(FunctionContext, Idxs, "fc_data",
EntryBB->getTerminator());
Idxs[1] = ConstantInt::get(Int32Ty, 1);
- Value *SelectorAddr = GetElementPtrInst::Create(FCData, Idxs, Idxs+2,
+ Value *SelectorAddr = GetElementPtrInst::Create(FCData, Idxs,
"exc_selector_gep",
EntryBB->getTerminator());
// The exception value comes back in context->data[0]
Idxs[1] = Zero;
- Value *ExceptionAddr = GetElementPtrInst::Create(FCData, Idxs, Idxs+2,
+ Value *ExceptionAddr = GetElementPtrInst::Create(FCData, Idxs,
"exception_gep",
EntryBB->getTerminator());
@@ -466,8 +464,7 @@
Idxs[0] = Zero;
Idxs[1] = ConstantInt::get(Int32Ty, 4);
Value *LSDAFieldPtr =
- GetElementPtrInst::Create(FunctionContext, Idxs, Idxs+2,
- "lsda_gep",
+ GetElementPtrInst::Create(FunctionContext, Idxs, "lsda_gep",
EntryBB->getTerminator());
Value *LSDA = CallInst::Create(LSDAAddrFn, "lsda_addr",
EntryBB->getTerminator());
@@ -475,8 +472,7 @@
Idxs[1] = ConstantInt::get(Int32Ty, 3);
Value *PersonalityFieldPtr =
- GetElementPtrInst::Create(FunctionContext, Idxs, Idxs+2,
- "lsda_gep",
+ GetElementPtrInst::Create(FunctionContext, Idxs, "lsda_gep",
EntryBB->getTerminator());
new StoreInst(PersonalityFn, PersonalityFieldPtr, true,
EntryBB->getTerminator());
@@ -484,12 +480,11 @@
// Save the frame pointer.
Idxs[1] = ConstantInt::get(Int32Ty, 5);
Value *JBufPtr
- = GetElementPtrInst::Create(FunctionContext, Idxs, Idxs+2,
- "jbuf_gep",
+ = GetElementPtrInst::Create(FunctionContext, Idxs, "jbuf_gep",
EntryBB->getTerminator());
Idxs[1] = ConstantInt::get(Int32Ty, 0);
Value *FramePtr =
- GetElementPtrInst::Create(JBufPtr, Idxs, Idxs+2, "jbuf_fp_gep",
+ GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep",
EntryBB->getTerminator());
Value *Val = CallInst::Create(FrameAddrFn,
@@ -501,7 +496,7 @@
// Save the stack pointer.
Idxs[1] = ConstantInt::get(Int32Ty, 2);
Value *StackPtr =
- GetElementPtrInst::Create(JBufPtr, Idxs, Idxs+2, "jbuf_sp_gep",
+ GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep",
EntryBB->getTerminator());
Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator());
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 25 04:48:08 2011
@@ -576,9 +576,7 @@
for (ScalarizeTable::iterator SI = ArgIndices.begin(),
E = ArgIndices.end(); SI != E; ++SI) {
// not allowed to dereference ->begin() if size() is 0
- Params.push_back(GetElementPtrInst::getIndexedType(I->getType(),
- SI->begin(),
- SI->end()));
+ Params.push_back(GetElementPtrInst::getIndexedType(I->getType(), *SI));
assert(Params.back());
}
@@ -668,7 +666,7 @@
ConstantInt::get(Type::getInt32Ty(F->getContext()), 0), 0 };
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
- Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2,
+ Value *Idx = GetElementPtrInst::Create(*AI, Idxs,
(*AI)->getName()+"."+utostr(i),
Call);
// TODO: Tell AA about the new values?
@@ -699,8 +697,7 @@
ElTy = cast(ElTy)->getTypeAtIndex(*II);
}
// And create a GEP to extract those indices.
- V = GetElementPtrInst::Create(V, Ops.begin(), Ops.end(),
- V->getName()+".idx", Call);
+ V = GetElementPtrInst::Create(V, Ops, V->getName()+".idx", Call);
Ops.clear();
AA.copyValue(OrigLoad->getOperand(0), V);
}
@@ -801,7 +798,7 @@
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
Value *Idx =
- GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
+ GetElementPtrInst::Create(TheAlloca, Idxs,
TheAlloca->getName()+"."+Twine(i),
InsertPt);
I2->setName(I->getName()+"."+Twine(i));
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Jul 25 04:48:08 2011
@@ -603,7 +603,7 @@
Idxs.push_back(NullInt);
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
Idxs.push_back(GEPI->getOperand(i));
- NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
+ NewPtr = GetElementPtrInst::Create(NewPtr, Idxs,
GEPI->getName()+"."+Twine(Val),GEPI);
}
}
@@ -1243,8 +1243,7 @@
GEPIdx.push_back(GEPI->getOperand(1));
GEPIdx.append(GEPI->op_begin()+3, GEPI->op_end());
- Value *NGEPI = GetElementPtrInst::Create(NewPtr,
- GEPIdx.begin(), GEPIdx.end(),
+ Value *NGEPI = GetElementPtrInst::Create(NewPtr, GEPIdx,
GEPI->getName(), GEPI);
GEPI->replaceAllUsesWith(NGEPI);
GEPI->eraseFromParent();
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Mon Jul 25 04:48:08 2011
@@ -1693,7 +1693,7 @@
// If we found a path from the src to dest, create the getelementptr now.
if (SrcElTy == DstElTy) {
SmallVector Idxs(NumZeros+1, ZeroUInt);
- return GetElementPtrInst::CreateInBounds(Src, Idxs.begin(), Idxs.end());
+ return GetElementPtrInst::CreateInBounds(Src, Idxs);
}
}
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Mon Jul 25 04:48:08 2011
@@ -58,8 +58,7 @@
Idx[0] = NullIdx;
Idx[1] = NullIdx;
Instruction *GEP =
- GetElementPtrInst::CreateInBounds(New, Idx, Idx + 2,
- New->getName()+".sub");
+ GetElementPtrInst::CreateInBounds(New, Idx, New->getName()+".sub");
InsertNewInstBefore(GEP, *It);
// Now make everything use the getelementptr instead of the original
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Mon Jul 25 04:48:08 2011
@@ -229,8 +229,8 @@
Value *Base = FixedOperands[0];
GetElementPtrInst *NewGEP =
- GetElementPtrInst::Create(Base, FixedOperands.begin()+1,
- FixedOperands.end());
+ GetElementPtrInst::Create(Base, makeArrayRef(FixedOperands.begin() + 1,
+ FixedOperands.end()));
if (AllInBounds) NewGEP->setIsInBounds();
NewGEP->setDebugLoc(FirstInst->getDebugLoc());
return NewGEP;
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Mon Jul 25 04:48:08 2011
@@ -851,10 +851,9 @@
if (!Indices.empty())
return (GEP.isInBounds() && Src->isInBounds()) ?
- GetElementPtrInst::CreateInBounds(Src->getOperand(0), Indices.begin(),
- Indices.end(), GEP.getName()) :
- GetElementPtrInst::Create(Src->getOperand(0), Indices.begin(),
- Indices.end(), GEP.getName());
+ GetElementPtrInst::CreateInBounds(Src->getOperand(0), Indices,
+ GEP.getName()) :
+ GetElementPtrInst::Create(Src->getOperand(0), Indices, GEP.getName());
}
// Handle gep(bitcast x) and gep(gep x, 0, 0, 0).
@@ -883,8 +882,7 @@
// -> GEP i8* X, ...
SmallVector Idx(GEP.idx_begin()+1, GEP.idx_end());
GetElementPtrInst *Res =
- GetElementPtrInst::Create(StrippedPtr, Idx.begin(),
- Idx.end(), GEP.getName());
+ GetElementPtrInst::Create(StrippedPtr, Idx, GEP.getName());
Res->setIsInBounds(GEP.isInBounds());
return Res;
}
Modified: llvm/trunk/lib/Transforms/Instrumentation/PathProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PathProfiling.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PathProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/PathProfiling.cpp Mon Jul 25 04:48:08 2011
@@ -1029,8 +1029,7 @@
gepIndices[1] = incValue;
GetElementPtrInst* pcPointer =
- GetElementPtrInst::Create(dag->getCounterArray(),
- gepIndices.begin(), gepIndices.end(),
+ GetElementPtrInst::Create(dag->getCounterArray(), gepIndices,
"counterInc", insertPoint);
// Load from the array - call it oldPC
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Jul 25 04:48:08 2011
@@ -2086,8 +2086,7 @@
}
Instruction *Val = NewElts[Idx];
if (NewArgs.size() > 1) {
- Val = GetElementPtrInst::CreateInBounds(Val, NewArgs.begin(),
- NewArgs.end(), "", GEPI);
+ Val = GetElementPtrInst::CreateInBounds(Val, NewArgs, "", GEPI);
Val->takeName(GEPI);
}
if (Val->getType() != GEPI->getType())
@@ -2163,7 +2162,7 @@
if (OtherPtr) {
Value *Idx[2] = { Zero,
ConstantInt::get(Type::getInt32Ty(MI->getContext()), i) };
- OtherElt = GetElementPtrInst::CreateInBounds(OtherPtr, Idx, Idx + 2,
+ OtherElt = GetElementPtrInst::CreateInBounds(OtherPtr, Idx,
OtherPtr->getName()+"."+Twine(i),
MI);
uint64_t EltOffset;
Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 25 04:48:08 2011
@@ -317,8 +317,7 @@
Idx[1] = ConstantInt::get(Type::getInt32Ty(header->getContext()), i);
TerminatorInst *TI = newFunction->begin()->getTerminator();
GetElementPtrInst *GEP =
- GetElementPtrInst::Create(AI, Idx, Idx+2,
- "gep_" + inputs[i]->getName(), TI);
+ GetElementPtrInst::Create(AI, Idx, "gep_" + inputs[i]->getName(), TI);
RewriteVal = new LoadInst(GEP, "loadgep_" + inputs[i]->getName(), TI);
} else
RewriteVal = AI++;
@@ -420,7 +419,7 @@
Idx[0] = Constant::getNullValue(Type::getInt32Ty(Context));
Idx[1] = ConstantInt::get(Type::getInt32Ty(Context), i);
GetElementPtrInst *GEP =
- GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+ GetElementPtrInst::Create(Struct, Idx,
"gep_" + StructValues[i]->getName());
codeReplacer->getInstList().push_back(GEP);
StoreInst *SI = new StoreInst(StructValues[i], GEP);
@@ -446,7 +445,7 @@
Idx[0] = Constant::getNullValue(Type::getInt32Ty(Context));
Idx[1] = ConstantInt::get(Type::getInt32Ty(Context), FirstOut + i);
GetElementPtrInst *GEP
- = GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+ = GetElementPtrInst::Create(Struct, Idx,
"gep_reload_" + outputs[i]->getName());
codeReplacer->getInstList().push_back(GEP);
Output = GEP;
@@ -561,7 +560,7 @@
Idx[1] = ConstantInt::get(Type::getInt32Ty(Context),
FirstOut+out);
GetElementPtrInst *GEP =
- GetElementPtrInst::Create(OAI, Idx, Idx + 2,
+ GetElementPtrInst::Create(OAI, Idx,
"gep_" + outputs[out]->getName(),
NTRet);
new StoreInst(outputs[out], GEP, NTRet);
Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Mon Jul 25 04:48:08 2011
@@ -455,8 +455,7 @@
Value *Idx[] = { Constant::getNullValue(Type::getInt32Ty(F.getContext())),
ConstantInt::get(Type::getInt32Ty(F.getContext()), 1) };
- OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, &Idx[0], &Idx[2],
- "OldBuf",
+ OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx, "OldBuf",
EntryBB->getTerminator());
// Copy the JBListHead to the alloca.
@@ -502,8 +501,7 @@
"setjmp.cont");
Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 0);
- Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, &Idx[0], &Idx[2],
- "TheJmpBuf",
+ Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx, "TheJmpBuf",
EntryBB->getTerminator());
JmpBufPtr = new BitCastInst(JmpBufPtr,
Type::getInt8PtrTy(F.getContext()),
@@ -557,8 +555,7 @@
// Get a pointer to the jmpbuf and longjmp.
Value *Idx[] = { Constant::getNullValue(Type::getInt32Ty(F.getContext())),
ConstantInt::get(Type::getInt32Ty(F.getContext()), 0) };
- Idx[0] = GetElementPtrInst::Create(BufPtr, &Idx[0], &Idx[2], "JmpBuf",
- UnwindBlock);
+ Idx[0] = GetElementPtrInst::Create(BufPtr, Idx, "JmpBuf", UnwindBlock);
Idx[0] = new BitCastInst(Idx[0],
Type::getInt8PtrTy(F.getContext()),
"tmp", UnwindBlock);
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Mon Jul 25 04:48:08 2011
@@ -2173,7 +2173,7 @@
if (isa(C)) {
PointerType *Ptr = cast(C->getType());
- Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs.begin(), Idxs.end());
+ Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
assert(Ty != 0 && "Invalid indices for GEP!");
return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
}
@@ -2187,8 +2187,7 @@
}
if (isNull) {
PointerType *Ptr = cast(C->getType());
- Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs.begin(),
- Idxs.end());
+ Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
assert(Ty != 0 && "Invalid indices for GEP!");
return ConstantPointerNull::get(PointerType::get(Ty,
Ptr->getAddressSpace()));
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 25 04:48:08 2011
@@ -1598,8 +1598,7 @@
return FC; // Fold a few common cases.
// Get the result type of the getelementptr!
- Type *Ty =
- GetElementPtrInst::getIndexedType(C->getType(), Idxs.begin(), Idxs.end());
+ Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), Idxs);
assert(Ty && "GEP indices invalid!");
unsigned AS = cast(C->getType())->getAddressSpace();
Type *ReqTy = Ty->getPointerTo(AS);
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Jul 25 04:48:08 2011
@@ -999,28 +999,11 @@
// GetElementPtrInst Implementation
//===----------------------------------------------------------------------===//
-static unsigned retrieveAddrSpace(const Value *Val) {
- return cast(Val->getType())->getAddressSpace();
-}
-
-void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx,
+void GetElementPtrInst::init(Value *Ptr, ArrayRef IdxList,
const Twine &Name) {
- assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
- Use *OL = OperandList;
- OL[0] = Ptr;
-
- for (unsigned i = 0; i != NumIdx; ++i)
- OL[i+1] = Idx[i];
-
- setName(Name);
-}
-
-void GetElementPtrInst::init(Value *Ptr, Value *Idx, const Twine &Name) {
- assert(NumOperands == 2 && "NumOperands not initialized?");
- Use *OL = OperandList;
- OL[0] = Ptr;
- OL[1] = Idx;
-
+ assert(NumOperands == 1 + IdxList.size() && "NumOperands not initialized?");
+ OperandList[0] = Ptr;
+ std::copy(IdxList.begin(), IdxList.end(), op_begin() + 1);
setName(Name);
}
@@ -1029,34 +1012,10 @@
OperandTraits::op_end(this)
- GEPI.getNumOperands(),
GEPI.getNumOperands()) {
- Use *OL = OperandList;
- Use *GEPIOL = GEPI.OperandList;
- for (unsigned i = 0, E = NumOperands; i != E; ++i)
- OL[i] = GEPIOL[i];
+ std::copy(GEPI.op_begin(), GEPI.op_end(), op_begin());
SubclassOptionalData = GEPI.SubclassOptionalData;
}
-GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const Twine &Name, Instruction *InBe)
- : Instruction(PointerType::get(
- checkGEPType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
- GetElementPtr,
- OperandTraits::op_end(this) - 2,
- 2, InBe) {
- init(Ptr, Idx, Name);
-}
-
-GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
- const Twine &Name, BasicBlock *IAE)
- : Instruction(PointerType::get(
- checkGEPType(getIndexedType(Ptr->getType(),Idx)),
- retrieveAddrSpace(Ptr)),
- GetElementPtr,
- OperandTraits::op_end(this) - 2,
- 2, IAE) {
- init(Ptr, Idx, Name);
-}
-
/// getIndexedType - Returns the type of the element that would be accessed with
/// a gep instruction with the specified parameters.
///
@@ -1067,14 +1026,13 @@
/// pointer type.
///
template
-static Type *getIndexedTypeInternal(Type *Ptr, IndexTy const *Idxs,
- unsigned NumIdx) {
+static Type *getIndexedTypeInternal(Type *Ptr, ArrayRef IdxList) {
PointerType *PTy = dyn_cast(Ptr);
if (!PTy) return 0; // Type isn't a pointer type!
Type *Agg = PTy->getElementType();
// Handle the special case of the empty set index set, which is always valid.
- if (NumIdx == 0)
+ if (IdxList.empty())
return Agg;
// If there is at least one index, the top level type must be sized, otherwise
@@ -1083,44 +1041,29 @@
return 0;
unsigned CurIdx = 1;
- for (; CurIdx != NumIdx; ++CurIdx) {
+ for (; CurIdx != IdxList.size(); ++CurIdx) {
CompositeType *CT = dyn_cast(Agg);
if (!CT || CT->isPointerTy()) return 0;
- IndexTy Index = Idxs[CurIdx];
+ IndexTy Index = IdxList[CurIdx];
if (!CT->indexValid(Index)) return 0;
Agg = CT->getTypeAtIndex(Index);
}
- return CurIdx == NumIdx ? Agg : 0;
+ return CurIdx == IdxList.size() ? Agg : 0;
}
-Type *GetElementPtrInst::getIndexedType(Type *Ptr, Value* const *Idxs,
- unsigned NumIdx) {
- return getIndexedTypeInternal(Ptr, Idxs, NumIdx);
+Type *GetElementPtrInst::getIndexedType(Type *Ptr, ArrayRef IdxList) {
+ return getIndexedTypeInternal(Ptr, IdxList);
}
Type *GetElementPtrInst::getIndexedType(Type *Ptr,
- Constant* const *Idxs,
- unsigned NumIdx) {
- return getIndexedTypeInternal(Ptr, Idxs, NumIdx);
+ ArrayRef IdxList) {
+ return getIndexedTypeInternal(Ptr, IdxList);
}
-Type *GetElementPtrInst::getIndexedType(Type *Ptr,
- uint64_t const *Idxs,
- unsigned NumIdx) {
- return getIndexedTypeInternal(Ptr, Idxs, NumIdx);
+Type *GetElementPtrInst::getIndexedType(Type *Ptr, ArrayRef IdxList) {
+ return getIndexedTypeInternal(Ptr, IdxList);
}
-Type *GetElementPtrInst::getIndexedType(Type *Ptr, Value *Idx) {
- PointerType *PTy = dyn_cast(Ptr);
- if (!PTy) return 0; // Type isn't a pointer type!
-
- // Check the pointer index.
- if (!PTy->indexValid(Idx)) return 0;
-
- return PTy->getElementType();
-}
-
-
/// hasAllZeroIndices - Return true if all of the indices of this GEP are
/// zeros. If so, the result pointer and the first operand have the same
/// value, just potentially different types.
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Jul 25 04:48:08 2011
@@ -1276,8 +1276,7 @@
void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) {
SmallVector Idxs(GEP.idx_begin(), GEP.idx_end());
Type *ElTy =
- GetElementPtrInst::getIndexedType(GEP.getOperand(0)->getType(),
- Idxs.begin(), Idxs.end());
+ GetElementPtrInst::getIndexedType(GEP.getOperand(0)->getType(), Idxs);
Assert1(ElTy, "Invalid indices for GEP pointer type!", &GEP);
Assert2(GEP.getType()->isPointerTy() &&
cast(GEP.getType())->getElementType() == ElTy,
Modified: llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Cloning.cpp?rev=135904&r1=135903&r2=135904&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/Cloning.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/Cloning.cpp Mon Jul 25 04:48:08 2011
@@ -124,7 +124,7 @@
Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
std::vector ops;
ops.push_back(Z);
- GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops.begin(), ops.end());
+ GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops);
EXPECT_FALSE(this->clone(GEP)->isInBounds());
GEP->setIsInBounds();
From jay.foad at gmail.com Mon Jul 25 05:14:44 2011
From: jay.foad at gmail.com (Jay Foad)
Date: Mon, 25 Jul 2011 10:14:44 -0000
Subject: [llvm-commits] [llvm] r135905 - in /llvm/trunk:
include/llvm/Constants.h lib/VMCore/Constants.cpp
Message-ID: <20110725101444.E384B2A6C12C@llvm.org>
Author: foad
Date: Mon Jul 25 05:14:44 2011
New Revision: 135905
URL: http://llvm.org/viewvc/llvm-project?rev=135905&view=rev
Log:
Use ArrayRef in the (protected) constructors of ConstantArray, ConstantStruct and ConstantVector.
Modified:
llvm/trunk/include/llvm/Constants.h
llvm/trunk/lib/VMCore/Constants.cpp
Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=135905&r1=135904&r2=135905&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Mon Jul 25 05:14:44 2011
@@ -329,7 +329,7 @@
std::vector >;
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected:
- ConstantArray(ArrayType *T, const std::vector &Val);
+ ConstantArray(ArrayType *T, ArrayRef Val);
public:
// ConstantArray accessors
static Constant *get(ArrayType *T, ArrayRef V);
@@ -400,7 +400,7 @@
std::vector >;
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected:
- ConstantStruct(StructType *T, const std::vector &Val);
+ ConstantStruct(StructType *T, ArrayRef Val);
public:
// ConstantStruct accessors
static Constant *get(StructType *T, ArrayRef V);
@@ -461,7 +461,7 @@
std::vector >;
ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
protected:
- ConstantVector(VectorType *T, const std::vector &Val);
+ ConstantVector(VectorType *T, ArrayRef Val);
public:
// ConstantVector accessors
static Constant *get(ArrayRef V);
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=135905&r1=135904&r2=135905&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 25 05:14:44 2011
@@ -573,21 +573,16 @@
//===----------------------------------------------------------------------===//
-ConstantArray::ConstantArray(ArrayType *T,
- const std::vector &V)
+ConstantArray::ConstantArray(ArrayType *T, ArrayRef V)
: Constant(T, ConstantArrayVal,
OperandTraits::op_end(this) - V.size(),
V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant array");
- Use *OL = OperandList;
- for (std::vector::const_iterator I = V.begin(), E = V.end();
- I != E; ++I, ++OL) {
- Constant *C = *I;
- assert(C->getType() == T->getElementType() &&
+ for (unsigned i = 0, e = V.size(); i != e; ++i)
+ assert(V[i]->getType() == T->getElementType() &&
"Initializer for array element doesn't match array element type!");
- *OL = C;
- }
+ std::copy(V.begin(), V.end(), op_begin());
}
Constant *ConstantArray::get(ArrayType *Ty, ArrayRef V) {
@@ -653,21 +648,16 @@
}
-ConstantStruct::ConstantStruct(StructType *T,
- const std::vector &V)
+ConstantStruct::ConstantStruct(StructType *T, ArrayRef V)
: Constant(T, ConstantStructVal,
OperandTraits::op_end(this) - V.size(),
V.size()) {
assert((T->isOpaque() || V.size() == T->getNumElements()) &&
"Invalid initializer vector for constant structure");
- Use *OL = OperandList;
- for (std::vector::const_iterator I = V.begin(), E = V.end();
- I != E; ++I, ++OL) {
- Constant *C = *I;
- assert((T->isOpaque() || C->getType() == T->getElementType(I-V.begin())) &&
+ for (unsigned i = 0, e = V.size(); i != e; ++i)
+ assert((T->isOpaque() || V[i]->getType() == T->getElementType(i)) &&
"Initializer for struct element doesn't match struct element type!");
- *OL = C;
- }
+ std::copy(V.begin(), V.end(), op_begin());
}
// ConstantStruct accessors.
@@ -692,19 +682,14 @@
return get(T, Values);
}
-ConstantVector::ConstantVector(VectorType *T,
- const std::vector &V)
+ConstantVector::ConstantVector(VectorType *T, ArrayRef V)
: Constant(T, ConstantVectorVal,
OperandTraits::op_end(this) - V.size(),
V.size()) {
- Use *OL = OperandList;
- for (std::vector::const_iterator I = V.begin(), E = V.end();
- I != E; ++I, ++OL) {
- Constant *C = *I;
- assert(C->getType() == T->getElementType() &&
+ for (size_t i = 0, e = V.size(); i != e; i++)
+ assert(V[i]->getType() == T->getElementType() &&
"Initializer for vector element doesn't match vector element type!");
- *OL = C;
- }
+ std::copy(V.begin(), V.end(), op_begin());
}
// ConstantVector accessors.
From jay.foad at gmail.com Mon Jul 25 05:32:27 2011
From: jay.foad at gmail.com (Jay Foad)
Date: Mon, 25 Jul 2011 10:32:27 -0000
Subject: [llvm-commits] [llvm] r135906 -
/llvm/trunk/include/llvm/Support/TypeBuilder.h
Message-ID: <20110725103227.81B6E2A6C12C@llvm.org>
Author: foad
Date: Mon Jul 25 05:32:27 2011
New Revision: 135906
URL: http://llvm.org/viewvc/llvm-project?rev=135906&view=rev
Log:
Remove uses of std::vector from TypeBuilder.
Modified:
llvm/trunk/include/llvm/Support/TypeBuilder.h
Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=135906&r1=135905&r2=135906&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TypeBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 25 05:32:27 2011
@@ -18,7 +18,6 @@
#include "llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
#include
-#include
namespace llvm {
@@ -254,9 +253,9 @@
template class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(1);
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, false);
}
@@ -265,10 +264,10 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(2);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, false);
}
@@ -277,11 +276,11 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(3);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, false);
}
@@ -292,12 +291,12 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(4);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, false);
}
@@ -308,13 +307,13 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(5);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, false);
}
@@ -330,9 +329,9 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(1);
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context), params, true);
}
};
@@ -340,10 +339,10 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(2);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, true);
}
@@ -352,11 +351,11 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(3);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, true);
}
@@ -367,12 +366,12 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(4);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, true);
}
@@ -383,13 +382,13 @@
class TypeBuilder {
public:
static FunctionType *get(LLVMContext &Context) {
- std::vector params;
- params.reserve(5);
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
- params.push_back(TypeBuilder::get(Context));
+ Type *params[] = {
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ TypeBuilder::get(Context),
+ };
return FunctionType::get(TypeBuilder::get(Context),
params, true);
}
From 6yearold at gmail.com Mon Jul 25 06:40:35 2011
From: 6yearold at gmail.com (arrowdodger)
Date: Mon, 25 Jul 2011 15:40:35 +0400
Subject: [llvm-commits] [PATCH][CMake] Connect llvmc tool to the build.
Message-ID:
I've wrote this by looking on according Makefiles. I haven't done anything
in doc/, since Makefiles do nothing there too.
The only thing i'm unsure is how do determine LLVM{GCC,GXX}COMMAND, so i
just hardcoded them to clang/clang++.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/ebc0e702/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvmc.cmake.patch
Type: text/x-patch
Size: 4340 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/ebc0e702/attachment.bin
From baldrick at free.fr Mon Jul 25 07:48:41 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 14:48:41 +0200
Subject: [llvm-commits] [llvm] r135362 -
/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
In-Reply-To: <20110717190500.7CE192A6C12C@llvm.org>
References: <20110717190500.7CE192A6C12C@llvm.org>
Message-ID: <4E2D6629.3080000@free.fr>
Hi Nadav,
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Sun Jul 17 14:05:00 2011
> @@ -2775,7 +2775,6 @@
>
>
> SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(SDNode *N) {
> -
> ShuffleVectorSDNode *SV = cast(N);
> EVT VT = N->getValueType(0);
> DebugLoc dl = N->getDebugLoc();
> @@ -2838,13 +2837,12 @@
> EVT NOutVTElem = NOutVT.getVectorElementType();
>
> DebugLoc dl = N->getDebugLoc();
> -
> - SDValue ConvertedVector = DAG.getNode(ISD::ANY_EXTEND, dl, NOutVT,
> - N->getOperand(0));
> + SDValue V0 = GetPromotedInteger(N->getOperand(0));
> + SDValue ConvertedVector = DAG.getNode(ISD::ANY_EXTEND, dl, NOutVT, V0);
>
> SDValue ConvElem = DAG.getNode(ISD::ANY_EXTEND, dl,
> NOutVTElem, N->getOperand(1));
> - return DAG.getNode(ISD::INSERT_VECTOR_ELT, dl,NOutVT,
> + return DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NOutVT,
> ConvertedVector, ConvElem, N->getOperand(2));
> }
since the input and output vector types are the same, as the output type is
promoted you know that the input type is promoted to the same type. Thus the
ANY_EXTEND of V0 must be a no-op and can be removed.
Ciao, Duncan.
From baldrick at free.fr Mon Jul 25 08:01:44 2011
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 25 Jul 2011 15:01:44 +0200
Subject: [llvm-commits] [llvm] r135471
- /llvm/trunk/test/Transforms/InstSimplify/compare.ll
In-Reply-To: <20110719082257.D4D482A6C12D@llvm.org>
References: <20110719082257.D4D482A6C12D@llvm.org>
Message-ID: <4E2D6938.6080800@free.fr>
Hi Nick,
> Remove bogus test: for all possible inputs of %X, the 'sub nsw' is guaranteed
> to perform a signed wrap. Don't rely on any particular handling of that case.
I don't understand what you are saying. "sub nsw" never does a signed wrap (if
it does the program performs undefined behaviour). In the testcase, %A is
positive while %B is negative. Thus %C is positive because there is no signed
wrap. Thus %D is positive or zero and %E is false.
Ciao, Duncan.
>
> Modified:
> llvm/trunk/test/Transforms/InstSimplify/compare.ll
>
> Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=135471&r1=135470&r2=135471&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original)
> +++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Tue Jul 19 03:22:57 2011
> @@ -283,17 +283,6 @@
> ret i1 %E
> }
>
> -; CHECK: @srem4
> -; CHECK-NEXT: ret i1 false
> -define i1 @srem4(i16 %X, i32 %Y) {
> - %A = zext i16 %X to i32
> - %B = or i32 2147483648, %A
> - %C = sub nsw i32 %A, %B
> - %D = srem i32 %C, %Y
> - %E = icmp slt i32 %D, 0
> - ret i1 %E
> -}
> -
> define i1 @udiv1(i32 %X) {
> ; CHECK: @udiv1
> %A = udiv i32 %X, 1000000
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
From ofv at wanadoo.es Mon Jul 25 09:10:24 2011
From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=)
Date: Mon, 25 Jul 2011 16:10:24 +0200
Subject: [llvm-commits] [PATCH][CMake] Connect llvmc tool to the build.
References:
Message-ID: <87mxg2ih7z.fsf@wanadoo.es>
arrowdodger <6yearold at gmail.com> writes:
> I've wrote this by looking on according Makefiles. I haven't done anything
> in doc/, since Makefiles do nothing there too.
>
> The only thing i'm unsure is how do determine LLVM{GCC,GXX}COMMAND, so i
> just hardcoded them to clang/clang++.
>
> Index: tools/llvmc/src/CMakeLists.txt
> ===================================================================
> --- tools/llvmc/src/CMakeLists.txt (revision 0)
> +++ tools/llvmc/src/CMakeLists.txt (revision 0)
> @@ -0,0 +1,25 @@
> +set(LLVMGCCCOMMAND ${CMAKE_BINARY_DIR}/bin/clang)
> +set(LLVMGXXCOMMAND ${CMAKE_BINARY_DIR}/bin/clang++)
The above will stop working once LLVM is installed and the build
directory removed, or when clang is not included in the build.
Maybe
set(LLVMGCCCOMMAND "${CMAKE_C_COMPILER}")
set(LLVMGCCCOMMAND "${CMAKE_CXX_COMPILER}")
?
> +configure_file(
> + ${CMAKE_CURRENT_SOURCE_DIR}/Base.td.in
> + ${CMAKE_CURRENT_BINARY_DIR}/Base.td
> + )
Please use the @ONLY option in that configure_file, just in case.
> +set(LLVM_TARGET_DEFINITIONS AutoGenerated.td)
> +
> +tablegen(AutoGenerated.inc -gen-llvmc)
> +
> +set(LLVM_USED_LIBS CompilerDriver)
> +set(LLVM_LINK_COMPONENTS support)
> +
> +add_llvm_tool(llvmc
> + Hooks.cpp
> + Main.cpp
> + )
The chunks of code like this:
> +add_custom_target(llvmc_gen ALL
> + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AutoGenerated.inc)
> +set_target_properties(llvmc_gen PROPERTIES FOLDER "Tablegenning")
> +
> +set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} llvmc_gen PARENT_SCOPE)
... are now unnecessary. I've just added support in add_llvm_executable
for automatically doing that.
> \ No newline at end of file
Please end the CMakeLists.txt files with a newline.
[snip]
> +set(LLVM_USED_LIBS CompilerDriver)
Why do you neeed CompilerDriver ?
[snip]
From ofv at wanadoo.es Mon Jul 25 09:11:55 2011
From: ofv at wanadoo.es (Oscar Fuentes)
Date: Mon, 25 Jul 2011 14:11:55 -0000
Subject: [llvm-commits] [llvm] r135908 - in /llvm/trunk/cmake/modules:
AddLLVM.cmake TableGen.cmake
Message-ID: <20110725141155.3C2422A6C12C@llvm.org>
Author: ofv
Date: Mon Jul 25 09:11:55 2011
New Revision: 135908
URL: http://llvm.org/viewvc/llvm-project?rev=135908&view=rev
Log:
CMake: generalize the system that creates custom targets for
tablegenning to all libraries and executables.
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/cmake/modules/TableGen.cmake
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=135908&r1=135907&r2=135908&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Mon Jul 25 09:11:55 2011
@@ -2,6 +2,7 @@
include(LLVM-Config)
macro(add_llvm_library name)
+ create_tablegenning_custom_target( ${name} )
llvm_process_sources( ALL_FILES ${ARGN} )
add_library( ${name} ${ALL_FILES} )
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
@@ -32,6 +33,7 @@
add_dependencies(${name} ${CURRENT_LLVM_TARGET})
endif()
set_target_properties(${name} PROPERTIES FOLDER "Libraries")
+ add_tablegenning_dependency( ${name} )
endmacro(add_llvm_library name)
@@ -75,6 +77,7 @@
macro(add_llvm_executable name)
+ create_tablegenning_custom_target( ${name} )
llvm_process_sources( ALL_FILES ${ARGN} )
if( EXCLUDE_FROM_ALL )
add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
@@ -88,6 +91,7 @@
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
link_system_libs( ${name} )
+ add_tablegenning_dependency( ${name} )
endmacro(add_llvm_executable name)
@@ -124,16 +128,7 @@
macro(add_llvm_target target_name)
- if( TABLEGEN_OUTPUT )
- add_custom_target(${target_name}Table_gen
- DEPENDS ${TABLEGEN_OUTPUT})
- add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
- endif( TABLEGEN_OUTPUT )
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
- if ( TABLEGEN_OUTPUT )
- add_dependencies(LLVM${target_name} ${target_name}Table_gen)
- set_target_properties(${target_name}Table_gen PROPERTIES FOLDER "Tablegenning")
- endif (TABLEGEN_OUTPUT)
set( CURRENT_LLVM_TARGET LLVM${target_name} )
endmacro(add_llvm_target)
Modified: llvm/trunk/cmake/modules/TableGen.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/TableGen.cmake?rev=135908&r1=135907&r2=135908&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/TableGen.cmake (original)
+++ llvm/trunk/cmake/modules/TableGen.cmake Mon Jul 25 09:11:55 2011
@@ -44,3 +44,24 @@
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn}
PROPERTIES GENERATED 1)
endmacro(tablegen)
+
+
+function(create_tablegenning_custom_target target)
+ # Creates the global target that runs the file-level dependencies
+ # for tablegenning.
+ if( TABLEGEN_OUTPUT )
+ add_custom_target(${target}Table_gen
+ DEPENDS ${TABLEGEN_OUTPUT})
+ add_dependencies(${target}Table_gen ${LLVM_COMMON_DEPENDS})
+ endif( TABLEGEN_OUTPUT )
+endfunction()
+
+function(add_tablegenning_dependency target)
+ # Makes the tablegenning step created with
+ # create_tablegenning_custom_target dependent on `target'.
+ if ( TABLEGEN_OUTPUT )
+ add_dependencies(${target} ${target}Table_gen)
+ set_target_properties(${target}Table_gen PROPERTIES FOLDER "Tablegenning")
+ endif (TABLEGEN_OUTPUT)
+endfunction()
+
From nadav.rotem at intel.com Mon Jul 25 09:33:32 2011
From: nadav.rotem at intel.com (Rotem, Nadav)
Date: Mon, 25 Jul 2011 17:33:32 +0300
Subject: [llvm-commits] [PATCH] Vector-select patch
Message-ID: <6594DDFF12B03D4E89690887C24869940296D9096B@hasmsx504.ger.corp.intel.com>
Hi,
Please review the attached file. The type legalization changes are mostly complete, and it is possible to match vector instructions. This patch contains the code-independent parts of the vector select.
Thanks,
Nadav
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/99d7a37f/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector_select_list.diff
Type: application/octet-stream
Size: 18597 bytes
Desc: vector_select_list.diff
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/99d7a37f/attachment.obj
From fvbommel at gmail.com Mon Jul 25 09:36:23 2011
From: fvbommel at gmail.com (Frits van Bommel)
Date: Mon, 25 Jul 2011 16:36:23 +0200
Subject: [llvm-commits] [llvm] r135904 - in /llvm/trunk: docs/
include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/
lib/Bitcode/Reader/ lib/CodeGen/ lib/Transforms/IPO/
lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms
Message-ID:
On 25 July 2011 11:48, Jay Foad wrote:
> --- llvm/trunk/lib/Analysis/PHITransAddr.cpp (original)
> +++ llvm/trunk/lib/Analysis/PHITransAddr.cpp Mon Jul 25 04:48:08 2011
> @@ -407,9 +407,10 @@
> ? ? }
>
> ? ? GetElementPtrInst *Result =
> - ? ?GetElementPtrInst::Create(GEPOps[0], GEPOps.begin()+1, GEPOps.end(),
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?InVal->getName()+".phi.trans.insert",
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?PredBB->getTerminator());
> + ? ? ?GetElementPtrInst::Create(GEPOps[0],
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?makeArrayRef(GEPOps.begin() + 1, GEPOps.end()),
'makeArrayRef(GEPOps).slice(1)' is nicer, and is the idiom used in
several other places.
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Mon Jul 25 04:48:08 2011
> @@ -229,8 +229,8 @@
>
> ? Value *Base = FixedOperands[0];
> ? GetElementPtrInst *NewGEP =
> - ? ?GetElementPtrInst::Create(Base, FixedOperands.begin()+1,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FixedOperands.end());
> + ? ?GetElementPtrInst::Create(Base, makeArrayRef(FixedOperands.begin() + 1,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? FixedOperands.end()));
makeArrayRef(FixedOperands).slice(1)
From jay.foad at gmail.com Mon Jul 25 09:49:09 2011
From: jay.foad at gmail.com (Jay Foad)
Date: Mon, 25 Jul 2011 15:49:09 +0100
Subject: [llvm-commits] [llvm] r135904 - in /llvm/trunk: docs/
include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/
lib/Bitcode/Reader/ lib/CodeGen/ lib/Transforms/IPO/
lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms
In-Reply-To:
References:
Message-ID:
On 25 July 2011 15:36, Frits van Bommel wrote:
> On 25 July 2011 11:48, Jay Foad wrote:
>> --- llvm/trunk/lib/Analysis/PHITransAddr.cpp (original)
>> +++ llvm/trunk/lib/Analysis/PHITransAddr.cpp Mon Jul 25 04:48:08 2011
>> @@ -407,9 +407,10 @@
>> ? ? }
>>
>> ? ? GetElementPtrInst *Result =
>> - ? ?GetElementPtrInst::Create(GEPOps[0], GEPOps.begin()+1, GEPOps.end(),
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?InVal->getName()+".phi.trans.insert",
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?PredBB->getTerminator());
>> + ? ? ?GetElementPtrInst::Create(GEPOps[0],
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?makeArrayRef(GEPOps.begin() + 1, GEPOps.end()),
>
> 'makeArrayRef(GEPOps).slice(1)' is nicer, and is the idiom used in
> several other places.
I considered both versions and chose this one. Why? Because I'm not
very familiar with slice(). It isn't in the STL (is it?) and it's not
immediately obvious to me, as a reader, what slice(a) and slice(a,b)
mean.
Feel free to change it if you want.
Jay.
From 6yearold at gmail.com Mon Jul 25 10:00:30 2011
From: 6yearold at gmail.com (arrowdodger)
Date: Mon, 25 Jul 2011 19:00:30 +0400
Subject: [llvm-commits] [PATCH][CMake] Connect llvmc tool to the build.
In-Reply-To: <87mxg2ih7z.fsf@wanadoo.es>
References:
<87mxg2ih7z.fsf@wanadoo.es>
Message-ID:
On Mon, Jul 25, 2011 at 6:10 PM, ?scar Fuentes wrote:
> > Index: tools/llvmc/src/CMakeLists.txt
> > ===================================================================
> > --- tools/llvmc/src/CMakeLists.txt (revision 0)
> > +++ tools/llvmc/src/CMakeLists.txt (revision 0)
> > @@ -0,0 +1,25 @@
> > +set(LLVMGCCCOMMAND ${CMAKE_BINARY_DIR}/bin/clang)
> > +set(LLVMGXXCOMMAND ${CMAKE_BINARY_DIR}/bin/clang++)
>
> The above will stop working once LLVM is installed and the build
> directory removed, or when clang is not included in the build.
>
> Maybe
>
> set(LLVMGCCCOMMAND "${CMAKE_C_COMPILER}")
> set(LLVMGCCCOMMAND "${CMAKE_CXX_COMPILER}")
>
> ?
>
CMAKE_C_COMPILER is not guaranteed to be able to -emit-llvm. As i've
understand, LLVM{GCC,GXX}COMMAND should point to clang, llvm-gcc or
dragonegg.
I've built LLVM with autotools and ran llvmc. It seems, LLVM{GCC,GXX}COMMAND
aren't contain absolute path, but just defaults to llvm-g{cc,++}. And there
is -clang option for llvmc, which changes llvm-g{cc,++} to clang{++}. So,
the soultion here is just
set(LLVMGCCCOMMAND llvm-gcc)
set(LLVMGCCCOMMAND llvm-g++)
But since llvm-gcc is almost dead, isn't it better to make clang default? Of
course, this would require changes in Makefiles for consistency and in llvmc
itself for option update.
> +set(LLVM_USED_LIBS CompilerDriver)
>
> Why do you neeed CompilerDriver ?
>
Because llvmc depends on it. In llvmc/src/Makefile there is line
LLVMC_BASED_DRIVER = llvmc
and in Makefile.rules there are following lines
ifdef LLVMC_BASED_DRIVER
LLVMLIBS = CompilerDriver.a
At last, removing set(LLVM_USED_LIBS CompilerDriver) causes linking
failures.
I've adressed your notes in updated patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/495f3089/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvmc.cmake.patch
Type: text/x-patch
Size: 3154 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110725/495f3089/attachment.bin
From fvbommel at gmail.com Mon Jul 25 10:13:01 2011
From: fvbommel at gmail.com (Frits van Bommel)
Date: Mon, 25 Jul 2011 15:13:01 -0000
Subject: [llvm-commits] [llvm] r135910 - in /llvm/trunk/lib:
Analysis/PHITransAddr.cpp Transforms/InstCombine/InstCombinePHI.cpp
Message-ID: <20110725151301.CBA102A6C124@llvm.org>
Author: fvbommel
Date: Mon Jul 25 10:13:01 2011
New Revision: 135910
URL: http://llvm.org/viewvc/llvm-project?rev=135910&view=rev
Log:
Shorten some expressions by using ArrayRef::slice().
Modified:
llvm/trunk/lib/Analysis/PHITransAddr.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
Modified: llvm/trunk/lib/Analysis/PHITransAddr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PHITransAddr.cpp?rev=135910&r1=135909&r2=135910&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/PHITransAddr.cpp (original)
+++ llvm/trunk/lib/Analysis/PHITransAddr.cpp Mon Jul 25 10:13:01 2011
@@ -407,8 +407,7 @@
}
GetElementPtrInst *Result =
- GetElementPtrInst::Create(GEPOps[0],
- makeArrayRef(GEPOps.begin() + 1, GEPOps.end()),
+ GetElementPtrInst::Create(GEPOps[0], makeArrayRef(GEPOps).slice(1),
InVal->getName()+".phi.trans.insert",
PredBB->getTerminator());
Result->setIsInBounds(GEP->isInBounds());
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=135910&r1=135909&r2=135910&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Mon Jul 25 10:13:01 2011
@@ -229,8 +229,7 @@
Value *Base = FixedOperands[0];
GetElementPtrInst *NewGEP =
- GetElementPtrInst::Create(Base, makeArrayRef(FixedOperands.begin() + 1,
- FixedOperands.end()));
+ GetElementPtrInst::Create(Base, makeArrayRef(FixedOperands).slice(1));
if (AllInBounds) NewGEP->setIsInBounds();
NewGEP->setDebugLoc(FirstInst->getDebugLoc());
return NewGEP;
From ofv at wanadoo.es Mon Jul 25 10:24:48 2011
From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=)
Date: Mon, 25 Jul 2011 17:24:48 +0200
Subject: [llvm-commits] [PATCH][CMake] Connect llvmc tool to the build.
In-Reply-To:
(arrowdodger's message of "Mon, 25 Jul 2011 19:00:30 +0400")
References:
<87mxg2ih7z.fsf@wanadoo.es>
Message-ID: <87hb6aidrz.fsf@wanadoo.es>
arrowdodger <6yearold at gmail.com> writes:
[snip]
Okay. Have you tested the build in Visual Studio? (with
LLVM_BUILD_EXAMPLES=ON)
From stoklund at 2pi.dk Mon Jul 25 10:25:43 2011
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Mon, 25 Jul 2011 15:25:43 -0000
Subject: [llvm-commits] [llvm] r135912 -
/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
Message-ID: <20110725152543.90ACE2A6C12D@llvm.org>
Author: stoklund
Date: Mon Jul 25 10:25:43 2011
New Revision: 135912
URL: http://llvm.org/viewvc/llvm-project?rev=135912&view=rev
Log:
Add an RS_Split2 stage used for loop prevention.
This mechanism already exists, but the RS_Split2 stage makes it clearer.
When live range splitting creates ranges that may not be making
progress, they are marked RS_Split2 instead of RS_New. These ranges may
be split again, but only in a way that can be proven to make progress.
For local ranges, that means they must be split into ranges used by
strictly fewer instructions.
For global ranges, region splitting is bypassed and the RS_Split2
ranges go straight to per-block splitting.
Modified:
llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=135912&r1=135911&r2=135912&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Mon Jul 25 10:25:43 2011
@@ -99,6 +99,11 @@
/// Attempt live range splitting if assignment is impossible.
RS_Split,
+ /// Attempt more aggressive live range splitting that is guaranteed to make
+ /// progress. This is used for split products that may not be making
+ /// progress.
+ RS_Split2,
+
/// Live range will be spilled. No more splitting will be attempted.
RS_Spill,
@@ -246,6 +251,7 @@
"RS_New",
"RS_Assign",
"RS_Split",
+ "RS_Split2",
"RS_Spill",
"RS_Done"
};
@@ -451,7 +457,7 @@
/// @param BreaksHint True when B is already assigned to its preferred register.
bool RAGreedy::shouldEvict(LiveInterval &A, bool IsHint,
LiveInterval &B, bool BreaksHint) {
- bool CanSplit = getStage(B) <= RS_Split;
+ bool CanSplit = getStage(B) < RS_Spill;
// Be fairly aggressive about following hints as long as the evictee can be
// split.
@@ -987,13 +993,13 @@
}
// Main interval. Allow repeated splitting as long as the number of live
- // blocks is strictly decreasing.
+ // blocks is strictly decreasing. Otherwise force per-block splitting.
if (IntvMap[i] == MainIntv) {
if (SA->countLiveBlocks(&Reg) >= OrigBlocks) {
DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks
<< " blocks as original.\n");
// Don't allow repeated splitting as a safe guard against looping.
- setStage(Reg, RS_Spill);
+ setStage(Reg, RS_Split2);
}
continue;
}
@@ -1180,17 +1186,17 @@
//
// Instead we use these rules:
//
- // 1. Allow any split for ranges with getStage() < RS_Spill. (Except for the
+ // 1. Allow any split for ranges with getStage() < RS_Split2. (Except for the
// noop split, of course).
- // 2. Require progress be made for ranges with getStage() >= RS_Spill. All
+ // 2. Require progress be made for ranges with getStage() == RS_Split2. All
// the new ranges must have fewer instructions than before the split.
- // 3. New ranges with the same number of instructions are marked RS_Spill,
+ // 3. New ranges with the same number of instructions are marked RS_Split2,
// smaller ranges are marked RS_New.
//
// These rules allow a 3 -> 2+3 split once, which we need. They also prevent
// excessive splitting and infinite loops.
//
- bool ProgressRequired = getStage(VirtReg) >= RS_Spill;
+ bool ProgressRequired = getStage(VirtReg) >= RS_Split2;
// Best split candidate.
unsigned BestBefore = NumGaps;
@@ -1309,7 +1315,7 @@
DebugVars->splitRegister(VirtReg.reg, LREdit.regs());
// If the new range has the same number of instructions as before, mark it as
- // RS_Spill so the next split will be forced to make progress. Otherwise,
+ // RS_Split2 so the next split will be forced to make progress. Otherwise,
// leave the new intervals as RS_New so they can compete.
bool LiveBefore = BestBefore != 0 || BI.LiveIn;
bool LiveAfter = BestAfter != NumGaps || BI.LiveOut;
@@ -1319,7 +1325,7 @@
assert(!ProgressRequired && "Didn't make progress when it was required.");
for (unsigned i = 0, e = IntvMap.size(); i != e; ++i)
if (IntvMap[i] == 1) {
- setStage(*LREdit.get(i), RS_Spill);
+ setStage(*LREdit.get(i), RS_Split2);
DEBUG(dbgs() << PrintReg(LREdit.get(i)->reg));
}
DEBUG(dbgs() << '\n');
@@ -1347,8 +1353,7 @@
NamedRegionTimer T("Global Splitting", TimerGroupName, TimePassesIsEnabled);
- // Don't iterate global splitting.
- // Move straight to spilling if this range was produced by a global split.
+ // Ranges must be Split2 or less.
if (getStage(VirtReg) >= RS_Spill)
return 0;
@@ -1365,10 +1370,14 @@
return PhysReg;
}
- // First try to split around a region spanning multiple blocks.
- unsigned PhysReg = tryRegionSplit(VirtReg, Order, NewVRegs);
- if (PhysReg || !NewVRegs.empty())
- return PhysReg;
+ // First try to split around a region spanning multiple blocks. RS_Split2
+ // ranges already made dubious progress with region splitting, so they go
+ // straight to single block splitting.
+ if (getStage(VirtReg) < RS_Split2) {
+ unsigned PhysReg = tryRegionSplit(VirtReg, Order, NewVRegs);
+ if (PhysReg || !NewVRegs.empty())
+ return PhysReg;
+ }
// Then isolate blocks with multiple uses.
SplitAnalysis::BlockPtrSet Blocks;
From stoklund at 2pi.dk Mon Jul 25 10:25:41 2011
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Mon, 25 Jul 2011 15:25:41 -0000
Subject: [llvm-commits] [llvm] r135911 -
/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
Message-ID: <20110725152541.379752A6C12C@llvm.org>
Author: stoklund
Date: Mon Jul 25 10:25:41 2011
New Revision: 135911
URL: http://llvm.org/viewvc/llvm-project?rev=135911&view=rev
Log:
Rename live range stages to better reflect how they are used.
The stage is used to control where a live range is going, not where it
is coming from. Live ranges created by splitting will usually be marked
RS_New, but some are marked RS_Spill to avoid wasting time trying to
split them again.
The old RS_Global and RS_Local stages are merged - they are really the
same thing for local and global live ranges.
Modified:
llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=135911&r1=135910&r2=135911&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Mon Jul 25 10:25:41 2011
@@ -90,12 +90,21 @@
// range splitting algorithm terminates, something that is otherwise hard to
// ensure.
enum LiveRangeStage {
- RS_New, ///< Never seen before.
- RS_First, ///< First time in the queue.
- RS_Second, ///< Second time in the queue.
- RS_Global, ///< Produced by global splitting.
- RS_Local, ///< Produced by local splitting.
- RS_Spill ///< Produced by spilling.
+ /// Newly created live range that has never been queued.
+ RS_New,
+
+ /// Only attempt assignment and eviction. Then requeue as RS_Split.
+ RS_Assign,
+
+ /// Attempt live range splitting if assignment is impossible.
+ RS_Split,
+
+ /// Live range will be spilled. No more splitting will be attempted.
+ RS_Spill,
+
+ /// There is nothing more we can do to this live range. Abort compilation
+ /// if it can't be assigned.
+ RS_Done
};
static const char *const StageName[];
@@ -234,12 +243,11 @@
#ifndef NDEBUG
const char *const RAGreedy::StageName[] = {
- "RS_New",
- "RS_First",
- "RS_Second",
- "RS_Global",
- "RS_Local",
- "RS_Spill"
+ "RS_New",
+ "RS_Assign",
+ "RS_Split",
+ "RS_Spill",
+ "RS_Done"
};
#endif
@@ -351,9 +359,9 @@
ExtraRegInfo.grow(Reg);
if (ExtraRegInfo[Reg].Stage == RS_New)
- ExtraRegInfo[Reg].Stage = RS_First;
+ ExtraRegInfo[Reg].Stage = RS_Assign;
- if (ExtraRegInfo[Reg].Stage == RS_Second)
+ if (ExtraRegInfo[Reg].Stage == RS_Split)
// Unsplit ranges that couldn't be allocated immediately are deferred until
// everything else has been allocated. Long ranges are allocated last so
// they are split against realistic interference.
@@ -443,7 +451,7 @@
/// @param BreaksHint True when B is already assigned to its preferred register.
bool RAGreedy::shouldEvict(LiveInterval &A, bool IsHint,
LiveInterval &B, bool BreaksHint) {
- bool CanSplit = getStage(B) <= RS_Second;
+ bool CanSplit = getStage(B) <= RS_Split;
// Be fairly aggressive about following hints as long as the evictee can be
// split.
@@ -488,7 +496,7 @@
if (TargetRegisterInfo::isPhysicalRegister(Intf->reg))
return false;
// Never evict spill products. They cannot split or spill.
- if (getStage(*Intf) == RS_Spill)
+ if (getStage(*Intf) == RS_Done)
return false;
// Once a live range becomes small enough, it is urgent that we find a
// register for it. This is indicated by an infinite spill weight. These
@@ -974,7 +982,7 @@
// Remainder interval. Don't try splitting again, spill if it doesn't
// allocate.
if (IntvMap[i] == 0) {
- setStage(Reg, RS_Global);
+ setStage(Reg, RS_Spill);
continue;
}
@@ -985,7 +993,7 @@
DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks
<< " blocks as original.\n");
// Don't allow repeated splitting as a safe guard against looping.
- setStage(Reg, RS_Global);
+ setStage(Reg, RS_Spill);
}
continue;
}
@@ -1172,17 +1180,17 @@
//
// Instead we use these rules:
//
- // 1. Allow any split for ranges with getStage() < RS_Local. (Except for the
+ // 1. Allow any split for ranges with getStage() < RS_Spill. (Except for the
// noop split, of course).
- // 2. Require progress be made for ranges with getStage() >= RS_Local. All
+ // 2. Require progress be made for ranges with getStage() >= RS_Spill. All
// the new ranges must have fewer instructions than before the split.
- // 3. New ranges with the same number of instructions are marked RS_Local,
+ // 3. New ranges with the same number of instructions are marked RS_Spill,
// smaller ranges are marked RS_New.
//
// These rules allow a 3 -> 2+3 split once, which we need. They also prevent
// excessive splitting and infinite loops.
//
- bool ProgressRequired = getStage(VirtReg) >= RS_Local;
+ bool ProgressRequired = getStage(VirtReg) >= RS_Spill;
// Best split candidate.
unsigned BestBefore = NumGaps;
@@ -1301,7 +1309,7 @@
DebugVars->splitRegister(VirtReg.reg, LREdit.regs());
// If the new range has the same number of instructions as before, mark it as
- // RS_Local so the next split will be forced to make progress. Otherwise,
+ // RS_Spill so the next split will be forced to make progress. Otherwise,
// leave the new intervals as RS_New so they can compete.
bool LiveBefore = BestBefore != 0 || BI.LiveIn;
bool LiveAfter = BestAfter != NumGaps || BI.LiveOut;
@@ -1311,7 +1319,7 @@
assert(!ProgressRequired && "Didn't make progress when it was required.");
for (unsigned i = 0, e = IntvMap.size(); i != e; ++i)
if (IntvMap[i] == 1) {
- setStage(*LREdit.get(i), RS_Local);
+ setStage(*LREdit.get(i), RS_Spill);
DEBUG(dbgs() << PrintReg(LREdit.get(i)->reg));
}
DEBUG(dbgs() << '\n');
@@ -1341,7 +1349,7 @@
// Don't iterate global splitting.
// Move straight to spilling if this range was produced by a global split.
- if (getStage(VirtReg) >= RS_Global)
+ if (getStage(VirtReg) >= RS_Spill)
return 0;
SA->analyze(&VirtReg);
@@ -1368,7 +1376,7 @@
LiveRangeEdit LREdit(VirtReg, NewVRegs, this);
SE->reset(LREdit);
SE->splitSingleBlocks(Blocks);
- setStage(NewVRegs.begin(), NewVRegs.end(), RS_Global);
+ setStage(NewVRegs.begin(), NewVRegs.end(), RS_Spill);
if (VerifyEnabled)
MF->verify(this, "After splitting live range around basic blocks");
}
@@ -1394,9 +1402,9 @@
<< " Cascade " << ExtraRegInfo[VirtReg.reg].Cascade << '\n');
// Try to evict a less worthy live range, but only for ranges from the primary
- // queue. The RS_Second ranges already failed to do this, and they should not
+ // queue. The RS_Split ranges already failed to do this, and they should not
// get a second chance until they have been split.
- if (Stage != RS_Second)
+ if (Stage != RS_Split)
if (unsigned PhysReg = tryEvict(VirtReg, Order, NewVRegs))
return PhysReg;
@@ -1405,8 +1413,8 @@
// The first time we see a live range, don't try to split or spill.
// Wait until the second time, when all smaller ranges have been allocated.
// This gives a better picture of the interference to split around.
- if (Stage == RS_First) {
- setStage(VirtReg, RS_Second);
+ if (Stage < RS_Split) {
+ setStage(VirtReg, RS_Split);
DEBUG(dbgs() << "wait for second round\n");
NewVRegs.push_back(&VirtReg);
return 0;
@@ -1414,7 +1422,7 @@
// If we couldn't allocate a register from spilling, there is probably some
// invalid inline assembly. The base class wil report it.
- if (Stage >= RS_Spill || !VirtReg.isSpillable())
+ if (Stage >= RS_Done || !VirtReg.isSpillable())
return ~0u;
// Try splitting VirtReg or interferences.
@@ -1426,7 +1434,7 @@
NamedRegionTimer T("Spiller", TimerGroupName, TimePassesIsEnabled);
LiveRangeEdit LRE(VirtReg, NewVRegs, this);
spiller().spill(LRE);
- setStage(NewVRegs.begin(), NewVRegs.end(), RS_Spill);
+ setStage(NewVRegs.begin(), NewVRegs.end(), RS_Done);
if (VerifyEnabled)
MF->verify(this, "After spilling");
From rafael.espindola at gmail.com Mon Jul 25 10:28:00 2011
From: rafael.espindola at gmail.com (Rafael Espindola)
Date: Mon, 25 Jul 2011 15:28:00 -0000
Subject: [llvm-commits] [llvm] r135913 - /llvm/trunk/docs/LangRef.html
Message-ID: <20110725152800.526952A6C12C@llvm.org>
Author: rafael
Date: Mon Jul 25 10:27:59 2011
New Revision: 135913
URL: http://llvm.org/viewvc/llvm-project?rev=135913&view=rev
Log:
Add uwtable to the langref.
Modified:
llvm/trunk/docs/LangRef.html
Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=135913&r1=135912&r2=135913&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Mon Jul 25 10:27:59 2011
@@ -1247,6 +1247,14 @@
function that doesn't have an sspreq attribute or which has
an ssp attribute, then the resulting function will have
an sspreq attribute.
+
+ uwtable
+ This attribute indicates that the ABI being targeted requires that
+ an unwind table entry be produce for this function even if we can
+ show that no exceptions passes by it. This is normally the case for
+ the ELF x86-64 abi, but it can be disabled for some compilation
+ units.
+
From grosbach at apple.com Mon Jul 25 12:11:29 2011
From: grosbach at apple.com (Jim Grosbach)
Date: Mon, 25 Jul 2011 17:11:29 -0000
Subject: [llvm-commits] [llvm] r135917 -
/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
Message-ID: <20110725171129.A6AAC2A6C12C@llvm.org>
Author: grosbach
Date: Mon Jul 25 12:11:29 2011
New Revision: 135917
URL: http://llvm.org/viewvc/llvm-project?rev=135917&view=rev
Log:
Tidy up. 80 columns.
Modified:
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=135917&r1=135916&r2=135917&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Mon Jul 25 12:11:29 2011
@@ -47,12 +47,17 @@
AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveRoData>(".rodata");
AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTData>(".tdata");
AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveTBSS>(".tbss");
- AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
- AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
- AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local");
- AddDirectiveHandler<&ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseSectionDirectiveDataRel>(".data.rel");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseSectionDirectiveDataRelRo>(".data.rel.ro");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseSectionDirectiveDataRelRoLocal>(".data.rel.ro.local");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseSectionDirectiveEhFrame>(".eh_frame");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSection>(".section");
- AddDirectiveHandler<&ELFAsmParser::ParseDirectivePushSection>(".pushsection");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseDirectivePushSection>(".pushsection");
AddDirectiveHandler<&ELFAsmParser::ParseDirectivePopSection>(".popsection");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSize>(".size");
AddDirectiveHandler<&ELFAsmParser::ParseDirectivePrevious>(".previous");
From ofv at wanadoo.es Mon Jul 25 12:24:54 2011
From: ofv at wanadoo.es (Oscar Fuentes)
Date: Mon, 25 Jul 2011 17:24:54 -0000
Subject: [llvm-commits] [llvm] r135918 -
/llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp
Message-ID: <20110725172454.3780C2A6C12C@llvm.org>
Author: ofv
Date: Mon Jul 25 12:24:54 2011
New Revision: 135918
URL: http://llvm.org/viewvc/llvm-project?rev=135918&view=rev
Log:
Fixes VS support for llvmc mcc16 llvmc example.
Patch by arrowdodger!
Modified:
llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp
Modified: llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp?rev=135918&r1=135917&r2=135918&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp (original)
+++ llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp Mon Jul 25 12:24:54 2011
@@ -3,9 +3,10 @@
#include "llvm/Support/raw_ostream.h"
#include
+#include
namespace llvmc {
- extern char *ProgramName;
+ extern const char *ProgramName;
namespace autogenerated {
extern llvm::cl::opt Parameter_p;
@@ -31,6 +32,7 @@
// It is __partname format in lower case.
std::string
GetLowerCasePartDefine(void) {
+ std::locale loc;
std::string Partname;
if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
@@ -40,7 +42,7 @@
std::string LowerCase;
for (unsigned i = 0; i < Partname.size(); i++) {
- LowerCase.push_back(std::tolower(Partname[i]));
+ LowerCase.push_back(std::tolower(Partname[i], loc));
}
return "__" + LowerCase;
@@ -48,6 +50,7 @@
std::string
GetUpperCasePartDefine(void) {
+ std::locale loc;
std::string Partname;
if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
@@ -57,7 +60,7 @@
std::string UpperCase;
for (unsigned i = 0; i < Partname.size(); i++) {
- UpperCase.push_back(std::toupper(Partname[i]));
+ UpperCase.push_back(std::toupper(Partname[i], loc));
}
return "__" + UpperCase;
From ofv at wanadoo.es Mon Jul 25 12:25:10 2011
From: ofv at wanadoo.es (Oscar Fuentes)
Date: Mon, 25 Jul 2011 17:25:10 -0000
Subject: [llvm-commits] [llvm] r135919 - in /llvm/trunk/tools/llvmc:
CMakeLists.txt examples/CMakeLists.txt examples/Hello/CMakeLists.txt
examples/Simple/CMakeLists.txt examples/Skeleton/CMakeLists.txt
examples/mcc16/CMakeLists.txt src/CMakeLists.txt
Message-ID: <20110725172510.935312A6C12C@llvm.org>
Author: ofv
Date: Mon Jul 25 12:25:10 2011
New Revision: 135919
URL: http://llvm.org/viewvc/llvm-project?rev=135919&view=rev
Log:
Builds llvmc and its examples with CMake.
Patch by arrowdodger!
Added:
llvm/trunk/tools/llvmc/examples/CMakeLists.txt
llvm/trunk/tools/llvmc/examples/Hello/CMakeLists.txt
llvm/trunk/tools/llvmc/examples/Simple/CMakeLists.txt
llvm/trunk/tools/llvmc/examples/Skeleton/CMakeLists.txt
llvm/trunk/tools/llvmc/examples/mcc16/CMakeLists.txt
llvm/trunk/tools/llvmc/src/CMakeLists.txt
Modified:
llvm/trunk/tools/llvmc/CMakeLists.txt
Modified: llvm/trunk/tools/llvmc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/CMakeLists.txt?rev=135919&r1=135918&r2=135919&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvmc/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -1,4 +1,8 @@
-# add_subdirectory(src)
+add_subdirectory(src)
# TODO: support plugins and user-configured builds.
# See ./doc/LLVMC-Reference.rst "Customizing LLVMC: the compilation graph"
+
+if( LLVM_INCLUDE_EXAMPLES )
+ add_subdirectory(examples)
+endif()
Added: llvm/trunk/tools/llvmc/examples/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/examples/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/examples/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,4 @@
+add_subdirectory(Hello)
+add_subdirectory(Simple)
+add_subdirectory(mcc16)
+add_subdirectory(Skeleton)
Added: llvm/trunk/tools/llvmc/examples/Hello/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/Hello/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/examples/Hello/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/examples/Hello/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,4 @@
+set(LLVM_USED_LIBS CompilerDriver)
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_example(Hello Hello.cpp)
Added: llvm/trunk/tools/llvmc/examples/Simple/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/Simple/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/examples/Simple/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/examples/Simple/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,10 @@
+set(LLVM_TARGET_DEFINITIONS Simple.td)
+
+tablegen(Simple.inc -gen-llvmc)
+
+set(LLVM_USED_LIBS CompilerDriver)
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_example(Simple
+ Simple.cpp
+ )
Added: llvm/trunk/tools/llvmc/examples/Skeleton/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/Skeleton/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/examples/Skeleton/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/examples/Skeleton/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,11 @@
+set(LLVM_TARGET_DEFINITIONS AutoGenerated.td)
+
+tablegen(AutoGenerated.inc -gen-llvmc)
+
+set(LLVM_USED_LIBS CompilerDriver)
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_example(llvmc-skeleton
+ Hooks.cpp
+ Main.cpp
+ )
Added: llvm/trunk/tools/llvmc/examples/mcc16/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/mcc16/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/examples/mcc16/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/examples/mcc16/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,11 @@
+set(LLVM_TARGET_DEFINITIONS PIC16.td)
+
+tablegen(PIC16.inc -gen-llvmc)
+
+set(LLVM_USED_LIBS CompilerDriver)
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_example(mcc16
+ Hooks.cpp
+ Main.cpp
+ )
Added: llvm/trunk/tools/llvmc/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/CMakeLists.txt?rev=135919&view=auto
==============================================================================
--- llvm/trunk/tools/llvmc/src/CMakeLists.txt (added)
+++ llvm/trunk/tools/llvmc/src/CMakeLists.txt Mon Jul 25 12:25:10 2011
@@ -0,0 +1,19 @@
+set(LLVMGCCCOMMAND llvm-gcc)
+set(LLVMGXXCOMMAND llvm-g++)
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Base.td.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Base.td
+ @ONLY)
+
+set(LLVM_TARGET_DEFINITIONS AutoGenerated.td)
+
+tablegen(AutoGenerated.inc -gen-llvmc)
+
+set(LLVM_USED_LIBS CompilerDriver)
+set(LLVM_LINK_COMPONENTS support)
+
+add_llvm_tool(llvmc
+ Hooks.cpp
+ Main.cpp
+ )
From ofv at wanadoo.es Mon Jul 25 12:26:48 2011
From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=)
Date: Mon, 25 Jul 2011 19:26:48 +0200
Subject: [llvm-commits] [PATCH][CMake] Connect llvmc tool to the build.
In-Reply-To:
(arrowdodger's message of "Mon, 25 Jul 2011 21:14:32 +0400")
References:
<87mxg2ih7z.fsf@wanadoo.es>
<87hb6aidrz.fsf@wanadoo.es>
<87d3gyicms.fsf@wanadoo.es>
Message-ID: <8739hui84n.fsf@wanadoo.es>
arrowdodger <6yearold at gmail.com> writes:
> 2011/7/25 ?scar Fuentes
>
>> Absolutely. We don't want to break the build for the VS users. CMake is
>> the only method they have for building LLVM.
>>
>
> Build on Windows unveiled fex bugs. After fixing them, i've successfully
> built llvmc and it's examples on Windows XP SP3 with VS2008.
> Updated patch attached.
Committed. Thanks!
From bruno.cardoso at gmail.com Mon Jul 25 12:55:41 2011
From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes)
Date: Mon, 25 Jul 2011 10:55:41 -0700
Subject: [llvm-commits] [PATCH] Vector-select patch
In-Reply-To: <6594DDFF12B03D4E89690887C24869940296D9096B@hasmsx504.ger.corp.intel.com>
References: <6594DDFF12B03D4E89690887C24869940296D9096B@hasmsx504.ger.corp.intel.com>
Message-ID:
Hi Nadav,
> Please review the attached file. The type legalization changes are mostly
> complete, and it is possible to match vector instructions. ?This patch
> contains the code-independent parts of the vector select.
MVT::SimpleValueType X86TargetLowering::getSetCCResultType(EVT VT) const {
- return MVT::i8;
+ if (!VT.isVector()) return MVT::i8;
+ switch (VT.getVectorNumElements()) {
+ default:
+ assert(false && "unknown vector size");
+ case 2: return MVT::v2i64;
+ case 4: return MVT::v4i32;
+ case 8: return MVT::v8i16;
+ case 16: return MVT::v16i8;
+ }
}
Could you please add the 256-bit AVX types here?
--
Bruno Cardoso Lopes
http://www.brunocardoso.cc
From grosbach at apple.com Mon Jul 25 12:55:35 2011
From: grosbach at apple.com (Jim Grosbach)
Date: Mon, 25 Jul 2011 17:55:35 -0000
Subject: [llvm-commits] [llvm] r135921 - in /llvm/trunk:
lib/MC/MCMachOStreamer.cpp lib/MC/MCParser/AsmParser.cpp
lib/MC/MCParser/COFFAsmParser.cpp lib/MC/MCParser/ELFAsmParser.cpp
test/MC/AsmParser/labels.s
Message-ID: <20110725175535.B63DD2A6C12D@llvm.org>
Author: grosbach
Date: Mon Jul 25 12:55:35 2011
New Revision: 135921
URL: http://llvm.org/viewvc/llvm-project?rev=135921&view=rev
Log:
Move some ELF directives into ELF asm parser.
The .local, .hidden, .internal, and .protected are not legal for all supported
file formats (in particular, they're invalid for MachO). Move the parsing for
them into the ELF assembly parser since that's the format they're for.
Similarly, .weak is used by COFF and ELF, but not MachO, so move the parsing
to the COFF and ELF asm parsers. Previously, using any of these directives
on Darwin would result in an assertion failure in the parser; now we get
a diagnostic as we should.
rdar://9827089
Modified:
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
llvm/trunk/test/MC/AsmParser/labels.s
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=135921&r1=135920&r2=135921&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon Jul 25 12:55:35 2011
@@ -207,7 +207,6 @@
case MCSA_ELF_TypeCommon:
case MCSA_ELF_TypeNoType:
case MCSA_ELF_TypeGnuUniqueObject:
- case MCSA_IndirectSymbol:
case MCSA_Hidden:
case MCSA_Internal:
case MCSA_Protected:
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=135921&r1=135920&r2=135921&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Jul 25 12:55:35 2011
@@ -1117,15 +1117,8 @@
if (IDVal == ".globl" || IDVal == ".global")
return ParseDirectiveSymbolAttribute(MCSA_Global);
- // ELF only? Should it be here?
- if (IDVal == ".local")
- return ParseDirectiveSymbolAttribute(MCSA_Local);
- if (IDVal == ".hidden")
- return ParseDirectiveSymbolAttribute(MCSA_Hidden);
if (IDVal == ".indirect_symbol")
return ParseDirectiveSymbolAttribute(MCSA_IndirectSymbol);
- if (IDVal == ".internal")
- return ParseDirectiveSymbolAttribute(MCSA_Internal);
if (IDVal == ".lazy_reference")
return ParseDirectiveSymbolAttribute(MCSA_LazyReference);
if (IDVal == ".no_dead_strip")
@@ -1134,12 +1127,8 @@
return ParseDirectiveSymbolAttribute(MCSA_SymbolResolver);
if (IDVal == ".private_extern")
return ParseDirectiveSymbolAttribute(MCSA_PrivateExtern);
- if (IDVal == ".protected")
- return ParseDirectiveSymbolAttribute(MCSA_Protected);
if (IDVal == ".reference")
return ParseDirectiveSymbolAttribute(MCSA_Reference);
- if (IDVal == ".weak")
- return ParseDirectiveSymbolAttribute(MCSA_Weak);
if (IDVal == ".weak_definition")
return ParseDirectiveSymbolAttribute(MCSA_WeakDefinition);
if (IDVal == ".weak_reference")
Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=135921&r1=135920&r2=135921&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Mon Jul 25 12:55:35 2011
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
@@ -72,6 +73,7 @@
".seh_pushframe");
AddDirectiveHandler<&COFFAsmParser::ParseSEHDirectiveEndProlog>(
".seh_endprologue");
+ AddDirectiveHandler<&COFFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
}
bool ParseSectionDirectiveText(StringRef, SMLoc) {
@@ -118,12 +120,44 @@
bool ParseAtUnwindOrAtExcept(bool &unwind, bool &except);
bool ParseSEHRegisterNumber(unsigned &RegNo);
+ bool ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc);
public:
COFFAsmParser() {}
};
} // end annonomous namespace.
+/// ParseDirectiveSymbolAttribute
+/// ::= { ".weak", ... } [ identifier ( , identifier )* ]
+bool COFFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
+ MCSymbolAttr Attr = StringSwitch(Directive)
+ .Case(".weak", MCSA_Weak)
+ .Default(MCSA_Invalid);
+ assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!");
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ for (;;) {
+ StringRef Name;
+
+ if (getParser().ParseIdentifier(Name))
+ return TokError("expected identifier in directive");
+
+ MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
+
+ getStreamer().EmitSymbolAttribute(Sym, Attr);
+
+ if (getLexer().is(AsmToken::EndOfStatement))
+ break;
+
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("unexpected token in directive");
+ Lex();
+ }
+ }
+
+ Lex();
+ return false;
+}
+
bool COFFAsmParser::ParseSectionSwitch(StringRef Section,
unsigned Characteristics,
SectionKind Kind) {
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=135921&r1=135920&r2=135921&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Mon Jul 25 12:55:35 2011
@@ -65,6 +65,14 @@
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
+ AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
+ AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseDirectiveSymbolAttribute>(".protected");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseDirectiveSymbolAttribute>(".internal");
+ AddDirectiveHandler<
+ &ELFAsmParser::ParseDirectiveSymbolAttribute>(".hidden");
}
// FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
@@ -134,6 +142,7 @@
bool ParseDirectiveIdent(StringRef, SMLoc);
bool ParseDirectiveSymver(StringRef, SMLoc);
bool ParseDirectiveWeakref(StringRef, SMLoc);
+ bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
private:
bool ParseSectionName(StringRef &SectionName);
@@ -141,6 +150,41 @@
}
+/// ParseDirectiveSymbolAttribute
+/// ::= { ".local", ".weak", ... } [ identifier ( , identifier )* ]
+bool ELFAsmParser::ParseDirectiveSymbolAttribute(StringRef Directive, SMLoc) {
+ MCSymbolAttr Attr = StringSwitch(Directive)
+ .Case(".weak", MCSA_Weak)
+ .Case(".local", MCSA_Local)
+ .Case(".hidden", MCSA_Hidden)
+ .Case(".internal", MCSA_Internal)
+ .Case(".protected", MCSA_Protected)
+ .Default(MCSA_Invalid);
+ assert(Attr != MCSA_Invalid && "unexpected symbol attribute directive!");
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ for (;;) {
+ StringRef Name;
+
+ if (getParser().ParseIdentifier(Name))
+ return TokError("expected identifier in directive");
+
+ MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
+
+ getStreamer().EmitSymbolAttribute(Sym, Attr);
+
+ if (getLexer().is(AsmToken::EndOfStatement))
+ break;
+
+ if (getLexer().isNot(AsmToken::Comma))
+ return TokError("unexpected token in directive");
+ Lex();
+ }
+ }
+
+ Lex();
+ return false;
+}
+
bool ELFAsmParser::ParseSectionSwitch(StringRef Section, unsigned Type,
unsigned Flags, SectionKind Kind) {
if (getLexer().isNot(AsmToken::EndOfStatement))
Modified: llvm/trunk/test/MC/AsmParser/labels.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/labels.s?rev=135921&r1=135920&r2=135921&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/labels.s (original)
+++ llvm/trunk/test/MC/AsmParser/labels.s Mon Jul 25 12:55:35 2011
@@ -35,9 +35,6 @@
// CHECK: .globl "a 3"
.globl "a 3"
-// CHECK: .weak "a 4"
- .weak "a 4"
-
// CHECK: .desc "a 5",1
.desc "a 5", 1
From isanbard at gmail.com Mon Jul 25 13:00:28 2011
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 25 Jul 2011 18:00:28 -0000
Subject: [llvm-commits] [llvm] r135922 - in /llvm/trunk/lib/Target/X86:
X86FrameLowering.cpp X86FrameLowering.h
Message-ID: <20110725180028.BC32C2A6C12C@llvm.org>
Author: void
Date: Mon Jul 25 13:00:28 2011
New Revision: 135922
URL: http://llvm.org/viewvc/llvm-project?rev=135922&view=rev
Log:
After we've modified the prolog to save volatile registers, generate the compact
unwind encoding for that function. This simply crawls through the prolog looking
for machine instrs marked as "frame setup". It can calculate from these what the
compact unwind should look like.
This is currently disabled because of needed linker support. But initial tests
look good.
Modified:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
llvm/trunk/lib/Target/X86/X86FrameLowering.h
Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=135922&r1=135921&r2=135922&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Jul 25 13:00:28 2011
@@ -283,8 +283,8 @@
}
void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
- MCSymbol *Label,
- unsigned FramePtr) const {
+ MCSymbol *Label,
+ unsigned FramePtr) const {
MachineFrameInfo *MFI = MF.getFrameInfo();
MachineModuleInfo &MMI = MF.getMMI();
@@ -346,6 +346,245 @@
}
}
+/// getCompactUnwindRegNum - Get the compact unwind number for a given
+/// register. The number corresponds to the enum lists in
+/// compact_unwind_encoding.h.
+static int getCompactUnwindRegNum(const unsigned *CURegs, unsigned Reg) {
+ int Idx = 1;
+ for (; *CURegs; ++CURegs, ++Idx)
+ if (*CURegs == Reg)
+ return Idx;
+
+ return -1;
+}
+
+/// encodeCompactUnwindRegistersWithoutFrame - Create the permutation encoding
+/// used with frameless stacks. It is passed the number of registers to be saved
+/// and an array of the registers saved.
+static uint32_t encodeCompactUnwindRegistersWithoutFrame(unsigned SavedRegs[6],
+ unsigned RegCount,
+ bool Is64Bit) {
+ // The saved registers are numbered from 1 to 6. In order to encode the order
+ // in which they were saved, we re-number them according to their place in the
+ // register order. The re-numbering is relative to the last re-numbered
+ // register. E.g., if we have registers {6, 2, 4, 5} saved in that order:
+ //
+ // Orig Re-Num
+ // ---- ------
+ // 6 6
+ // 2 2
+ // 4 3
+ // 5 3
+ //
+ static const unsigned CU32BitRegs[] = {
+ X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
+ };
+ static const unsigned CU64BitRegs[] = {
+ X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
+ };
+ const unsigned *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
+
+ uint32_t RenumRegs[6];
+ for (unsigned i = 6 - RegCount; i < 6; ++i) {
+ int CUReg = getCompactUnwindRegNum(CURegs, SavedRegs[i]);
+ if (CUReg == -1) return ~0U;
+ SavedRegs[i] = CUReg;
+
+ unsigned Countless = 0;
+ for (unsigned j = 6 - RegCount; j < i; ++j)
+ if (SavedRegs[j] < SavedRegs[i])
+ ++Countless;
+
+ RenumRegs[i] = SavedRegs[i] - Countless - 1;
+ }
+
+ // Take the renumbered values and encode them into a 10-bit number.
+ uint32_t permutationEncoding = 0;
+ switch (RegCount) {
+ case 6:
+ permutationEncoding |= 120 * RenumRegs[0] + 24 * RenumRegs[1]
+ + 6 * RenumRegs[2] + 2 * RenumRegs[3]
+ + RenumRegs[4];
+ break;
+ case 5:
+ permutationEncoding |= 120 * RenumRegs[1] + 24 * RenumRegs[2]
+ + 6 * RenumRegs[3] + 2 * RenumRegs[4]
+ + RenumRegs[5];
+ break;
+ case 4:
+ permutationEncoding |= 60 * RenumRegs[2] + 12 * RenumRegs[3]
+ + 3 * RenumRegs[4] + RenumRegs[5];
+ break;
+ case 3:
+ permutationEncoding |= 20 * RenumRegs[3] + 4 * RenumRegs[4]
+ + RenumRegs[5];
+ break;
+ case 2:
+ permutationEncoding |= 5 * RenumRegs[4] + RenumRegs[5];
+ break;
+ case 1:
+ permutationEncoding |= RenumRegs[5];
+ break;
+ }
+
+ assert((permutationEncoding & 0x3FF) == permutationEncoding &&
+ "Invalid compact register encoding!");
+ return permutationEncoding;
+}
+
+/// encodeCompactUnwindRegistersWithFrame - Return the registers encoded for a
+/// compact encoding with a frame pointer.
+static uint32_t encodeCompactUnwindRegistersWithFrame(unsigned SavedRegs[6],
+ bool Is64Bit) {
+ static const unsigned CU32BitRegs[] = {
+ X86::EBX, X86::ECX, X86::EDX, X86::EDI, X86::ESI, X86::EBP, 0
+ };
+ static const unsigned CU64BitRegs[] = {
+ X86::RBX, X86::R12, X86::R13, X86::R14, X86::R15, X86::RBP, 0
+ };
+ const unsigned *CURegs = (Is64Bit ? CU64BitRegs : CU32BitRegs);
+
+ // Encode the registers in the order they were saved, 3-bits per register. The
+ // registers are numbered from 1 to 6.
+ uint32_t RegEnc = 0;
+ for (int I = 5; I >= 0; --I) {
+ unsigned Reg = SavedRegs[I];
+ if (Reg == 0) break;
+ int CURegNum = getCompactUnwindRegNum(CURegs, Reg);
+ if (CURegNum == -1)
+ return ~0U;
+ RegEnc |= (CURegNum & 0x7) << (5 - I);
+ }
+
+ assert((RegEnc & 0x7FFF) == RegEnc && "Invalid compact register encoding!");
+ return RegEnc;
+}
+
+uint32_t X86FrameLowering::getCompactUnwindEncoding(MachineFunction &MF) const {
+ const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
+ unsigned FramePtr = RegInfo->getFrameRegister(MF);
+ unsigned StackPtr = RegInfo->getStackRegister();
+
+ X86MachineFunctionInfo *X86FI = MF.getInfo();
+ int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
+
+ bool Is64Bit = STI.is64Bit();
+ bool HasFP = hasFP(MF);
+
+ unsigned SavedRegs[6] = { 0, 0, 0, 0, 0, 0 };
+ int SavedRegIdx = 6;
+
+ unsigned OffsetSize = (Is64Bit ? 8 : 4);
+
+ unsigned PushInstr = (Is64Bit ? X86::PUSH64r : X86::PUSH32r);
+ unsigned PushInstrSize = 1;
+ unsigned MoveInstr = (Is64Bit ? X86::MOV64rr : X86::MOV32rr);
+ unsigned MoveInstrSize = (Is64Bit ? 3 : 2);
+ unsigned SubtractInstr = getSUBriOpcode(Is64Bit, -TailCallReturnAddrDelta);
+ unsigned SubtractInstrIdx = (Is64Bit ? 3 : 2);
+
+ unsigned InstrOffset = 0;
+ unsigned CFAOffset = 0;
+ unsigned StackAdjust = 0;
+
+ MachineBasicBlock &MBB = MF.front(); // Prologue is in entry BB.
+ bool ExpectEnd = false;
+ for (MachineBasicBlock::iterator
+ MBBI = MBB.begin(), MBBE = MBB.end(); MBBI != MBBE; ++MBBI) {
+ MachineInstr &MI = *MBBI;
+ unsigned Opc = MI.getOpcode();
+ if (Opc == X86::PROLOG_LABEL) continue;
+ if (!MI.getFlag(MachineInstr::FrameSetup)) break;
+
+ // We don't exect any more prolog instructions.
+ if (ExpectEnd) return 0;
+
+ if (Opc == PushInstr) {
+ // If there are too many saved registers, we cannot use compact encoding.
+ if (--SavedRegIdx < 0) return 0;
+
+ SavedRegs[SavedRegIdx] = MI.getOperand(0).getReg();
+ CFAOffset += OffsetSize;
+ InstrOffset += PushInstrSize;
+ } else if (Opc == MoveInstr) {
+ unsigned SrcReg = MI.getOperand(1).getReg();
+ unsigned DstReg = MI.getOperand(0).getReg();
+
+ if (DstReg != FramePtr || SrcReg != StackPtr)
+ return 0;
+
+ CFAOffset = 0;
+ memset(SavedRegs, 0, sizeof(SavedRegs));
+ InstrOffset += MoveInstrSize;
+ } else if (Opc == SubtractInstr) {
+ if (StackAdjust)
+ // We all ready have a stack pointer adjustment.
+ return 0;
+
+ if (!MI.getOperand(0).isReg() ||
+ MI.getOperand(0).getReg() != MI.getOperand(1).getReg() ||
+ MI.getOperand(0).getReg() != StackPtr || !MI.getOperand(2).isImm())
+ // We need this to be a stack adjustment pointer. Something like:
+ //
+ // %RSP = SUB64ri8 %RSP, 48
+ return 0;
+
+ StackAdjust = MI.getOperand(2).getImm() / 4;
+ SubtractInstrIdx += InstrOffset;
+ ExpectEnd = true;
+ }
+ }
+
+ // Encode that we are using EBP/RBP as the frame pointer.
+ uint32_t CompactUnwindEncoding = 0;
+ CFAOffset /= 4;
+ if (HasFP) {
+ if ((CFAOffset & 0xFF) != CFAOffset)
+ // Offset was too big for compact encoding.
+ return 0;
+
+ // Get the encoding of the saved registers when we have a frame pointer.
+ uint32_t RegEnc = encodeCompactUnwindRegistersWithFrame(SavedRegs, Is64Bit);
+ if (RegEnc == ~0U)
+ return 0;
+
+ CompactUnwindEncoding |= 0x01000000;
+ CompactUnwindEncoding |= (CFAOffset & 0xFF) << 16;
+ CompactUnwindEncoding |= RegEnc & 0x7FFF;
+ } else {
+ unsigned FullOffset = CFAOffset + StackAdjust;
+ if ((FullOffset & 0xFF) == FullOffset) {
+ // Frameless stack.
+ CompactUnwindEncoding |= 0x02000000;
+ CompactUnwindEncoding |= (FullOffset & 0xFF) << 16;
+ } else {
+ if ((CFAOffset & 0x7) != CFAOffset)
+ // The extra stack adjustments are too big for us to handle.
+ return 0;
+
+ // Frameless stack with an offset too large for us to encode compactly.
+ CompactUnwindEncoding |= 0x03000000;
+
+ // Encode the offset to the nnnnnn value in the 'subl $nnnnnn, ESP'
+ // instruction.
+ CompactUnwindEncoding |= (SubtractInstrIdx & 0xFF) << 16;
+
+ // Encode any extra stack stack changes (done via push instructions).
+ CompactUnwindEncoding |= (CFAOffset & 0x7) << 13;
+ }
+
+ // Get the encoding of the saved registers when we don't have a frame
+ // pointer.
+ uint32_t RegEnc = encodeCompactUnwindRegistersWithoutFrame(SavedRegs,
+ 6 - SavedRegIdx,
+ Is64Bit);
+ if (RegEnc == ~0U) return 0;
+ CompactUnwindEncoding |= RegEnc & 0x3FF;
+ }
+
+ return CompactUnwindEncoding;
+}
+
/// emitPrologue - Push callee-saved registers onto the stack, which
/// automatically adjust the stack pointer. Adjust the stack pointer to allocate
/// space for local variables. Also emit labels used by the exception handler to
@@ -478,7 +717,7 @@
Moves.push_back(MachineMove(FrameLabel, FPDst, FPSrc));
}
- // Update EBP with the new base value...
+ // Update EBP with the new base value.
BuildMI(MBB, MBBI, DL,
TII.get(Is64Bit ? X86::MOV64rr : X86::MOV32rr), FramePtr)
.addReg(StackPtr)
@@ -520,6 +759,7 @@
// Skip the callee-saved push instructions.
bool PushedRegs = false;
int StackOffset = 2 * stackGrowth;
+ SmallVector SavedRegs;
while (MBBI != MBB.end() &&
(MBBI->getOpcode() == X86::PUSH32r ||
@@ -534,8 +774,7 @@
BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(Label);
// Define the current CFA rule to use the provided offset.
- unsigned Ptr = StackSize ?
- MachineLocation::VirtualFP : StackPtr;
+ unsigned Ptr = StackSize ? MachineLocation::VirtualFP : StackPtr;
MachineLocation SPDst(Ptr);
MachineLocation SPSrc(Ptr, StackOffset);
Moves.push_back(MachineMove(Label, SPDst, SPSrc));
@@ -657,6 +896,11 @@
if (PushedRegs)
emitCalleeSavedFrameMoves(MF, Label, HasFP ? FramePtr : StackPtr);
}
+
+ // Darwin 10.7 and greater has support for compact unwind encoding.
+ if (false && // FIXME: Enable once linker support is available.
+ STI.isTargetDarwin() && !STI.getTargetTriple().isMacOSXVersionLT(10, 6))
+ MMI.setCompactUnwindEncoding(getCompactUnwindEncoding(MF));
}
void X86FrameLowering::emitEpilogue(MachineFunction &MF,
Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.h?rev=135922&r1=135921&r2=135922&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.h Mon Jul 25 13:00:28 2011
@@ -58,6 +58,7 @@
bool hasReservedCallFrame(const MachineFunction &MF) const;
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
+ uint32_t getCompactUnwindEncoding(MachineFunction &MF) const;
};
} // End llvm namespace
From isanbard at gmail.com Mon Jul 25 13:01:27 2011
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 25 Jul 2011 18:01:27 -0000
Subject: [llvm-commits] [llvm] r135923 -
/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
Message-ID: <20110725180127.44AC72A6C12C@llvm.org>
Author: void
Date: Mon Jul 25 13:01:27 2011
New Revision: 135923
URL: http://llvm.org/viewvc/llvm-project?rev=135923&view=rev
Log:
Remove dead variable.
Modified:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=135923&r1=135922&r2=135923&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Jul 25 13:01:27 2011
@@ -759,7 +759,6 @@
// Skip the callee-saved push instructions.
bool PushedRegs = false;
int StackOffset = 2 * stackGrowth;
- SmallVector SavedRegs;
while (MBBI != MBB.end() &&
(MBBI->getOpcode() == X86::PUSH32r ||
From isanbard at gmail.com Mon Jul 25 13:04:49 2011
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 25 Jul 2011 18:04:49 -0000
Subject: [llvm-commits] [llvm] r135924 -
/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
Message-ID: <20110725180449.585D12A6C12C@llvm.org>
Author: void
Date: Mon Jul 25 13:04:49 2011
New Revision: 135924
URL: http://llvm.org/viewvc/llvm-project?rev=135924&view=rev
Log:
Changed disabled code into a flag.
Modified:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=135924&r1=135923&r2=135924&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Jul 25 13:04:49 2011
@@ -34,6 +34,12 @@
// FIXME: completely move here.
extern cl::opt ForceStackAlign;
+// FIXME: Remove once linker support is available.
+static cl::opt
+GenerateCompactUnwind("gen-compact-unwind",
+ cl::desc("Generate compact unwind encoding"),
+ cl::Hidden);
+
bool X86FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
return !MF.getFrameInfo()->hasVarSizedObjects();
}
@@ -897,7 +903,7 @@
}
// Darwin 10.7 and greater has support for compact unwind encoding.
- if (false && // FIXME: Enable once linker support is available.
+ if (GenerateCompactUnwind &&
STI.isTargetDarwin() && !STI.getTargetTriple().isMacOSXVersionLT(10, 6))
MMI.setCompactUnwindEncoding(getCompactUnwindEncoding(MF));
}
From criswell at uiuc.edu Mon Jul 25 13:06:52 2011
From: criswell at uiuc.edu (John Criswell)
Date: Mon, 25 Jul 2011 18:06:52 -0000
Subject: [llvm-commits] [poolalloc] r135926 - /poolalloc/branches/release_27/
Message-ID: <20110725180652.E270E2A6C12C@llvm.org>
Author: criswell
Date: Mon Jul 25 13:06:52 2011
New Revision: 135926
URL: http://llvm.org/viewvc/llvm-project?rev=135926&view=rev
Log:
Creating the release_27 branch of poolalloc.
Added:
poolalloc/branches/release_27/ (props changed)
- copied from r135925, poolalloc/trunk/
Propchange: poolalloc/branches/release_27/
------------------------------------------------------------------------------
svn:mergeinfo = /poolalloc/branches/release_26:97820-104253
From evan.cheng at apple.com Mon Jul 25 13:43:53 2011
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 25 Jul 2011 18:43:53 -0000
Subject: [llvm-commits] [llvm] r135930 - in /llvm/trunk/lib:
MC/ELFObjectWriter.cpp MC/WinCOFFObjectWriter.cpp
Target/X86/MCTargetDesc/X86BaseInfo.h
Target/X86/MCTargetDesc/X86FixupKinds.h
Target/X86/MCTargetDesc/X86MCTargetDesc.h Target/X86/X86.h
Target/X86/X86AsmBackend.cpp Target/X86/X86CodeEmitter.cpp
Target/X86/X86FixupKinds.h Target/X86/X86InstrInfo.cpp
Target/X86/X86InstrInfo.h Target/X86/X86MCCodeEmitter.cpp
Target/X86/X86MachObjectWriter.cpp
Message-ID: <20110725184353.94E452A6C12C@llvm.org>
Author: evancheng
Date: Mon Jul 25 13:43:53 2011
New Revision: 135930
URL: http://llvm.org/viewvc/llvm-project?rev=135930&view=rev
Log:
Refactor X86 target to separate MC code from Target code.
Added:
llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
llvm/trunk/lib/Target/X86/MCTargetDesc/X86FixupKinds.h
- copied unchanged from r135824, llvm/trunk/lib/Target/X86/X86FixupKinds.h
Removed:
llvm/trunk/lib/Target/X86/X86FixupKinds.h
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
llvm/trunk/lib/Target/X86/X86.h
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.h
llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Jul 25 13:43:53 2011
@@ -28,7 +28,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSwitch.h"
-#include "../Target/X86/X86FixupKinds.h"
+#include "../Target/X86/MCTargetDesc/X86FixupKinds.h"
#include "../Target/ARM/MCTargetDesc/ARMFixupKinds.h"
#include
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Mon Jul 25 13:43:53 2011
@@ -33,7 +33,7 @@
#include "llvm/Support/TimeValue.h"
-#include "../Target/X86/X86FixupKinds.h"
+#include "../Target/X86/MCTargetDesc/X86FixupKinds.h"
#include
Added: llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h?rev=135930&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (added)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h Mon Jul 25 13:43:53 2011
@@ -0,0 +1,544 @@
+//===-- X86BaseInfo.h - Top level definitions for X86 -------- --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains small standalone helper functions and enum definitions for
+// the X86 target useful for the compiler back-end and the MC libraries.
+// As such, it deliberately does not include references to LLVM core
+// code gen types, passes, etc..
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef X86BASEINFO_H
+#define X86BASEINFO_H
+
+#include "X86MCTargetDesc.h"
+#include "llvm/Support/DataTypes.h"
+#include
+
+namespace llvm {
+
+namespace X86 {
+ // Enums for memory operand decoding. Each memory operand is represented with
+ // a 5 operand sequence in the form:
+ // [BaseReg, ScaleAmt, IndexReg, Disp, Segment]
+ // These enums help decode this.
+ enum {
+ AddrBaseReg = 0,
+ AddrScaleAmt = 1,
+ AddrIndexReg = 2,
+ AddrDisp = 3,
+
+ /// AddrSegmentReg - The operand # of the segment in the memory operand.
+ AddrSegmentReg = 4,
+
+ /// AddrNumOperands - Total number of operands in a memory reference.
+ AddrNumOperands = 5
+ };
+} // end namespace X86;
+
+
+/// X86II - This namespace holds all of the target specific flags that
+/// instruction info tracks.
+///
+namespace X86II {
+ /// Target Operand Flag enum.
+ enum TOF {
+ //===------------------------------------------------------------------===//
+ // X86 Specific MachineOperand flags.
+
+ MO_NO_FLAG,
+
+ /// MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a
+ /// relocation of:
+ /// SYMBOL_LABEL + [. - PICBASELABEL]
+ MO_GOT_ABSOLUTE_ADDRESS,
+
+ /// MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the
+ /// immediate should get the value of the symbol minus the PIC base label:
+ /// SYMBOL_LABEL - PICBASELABEL
+ MO_PIC_BASE_OFFSET,
+
+ /// MO_GOT - On a symbol operand this indicates that the immediate is the
+ /// offset to the GOT entry for the symbol name from the base of the GOT.
+ ///
+ /// See the X86-64 ELF ABI supplement for more details.
+ /// SYMBOL_LABEL @GOT
+ MO_GOT,
+
+ /// MO_GOTOFF - On a symbol operand this indicates that the immediate is
+ /// the offset to the location of the symbol name from the base of the GOT.
+ ///
+ /// See the X86-64 ELF ABI supplement for more details.
+ /// SYMBOL_LABEL @GOTOFF
+ MO_GOTOFF,
+
+ /// MO_GOTPCREL - On a symbol operand this indicates that the immediate is
+ /// offset to the GOT entry for the symbol name from the current code
+ /// location.
+ ///
+ /// See the X86-64 ELF ABI supplement for more details.
+ /// SYMBOL_LABEL @GOTPCREL
+ MO_GOTPCREL,
+
+ /// MO_PLT - On a symbol operand this indicates that the immediate is
+ /// offset to the PLT entry of symbol name from the current code location.
+ ///
+ /// See the X86-64 ELF ABI supplement for more details.
+ /// SYMBOL_LABEL @PLT
+ MO_PLT,
+
+ /// MO_TLSGD - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// See 'ELF Handling for Thread-Local Storage' for more details.
+ /// SYMBOL_LABEL @TLSGD
+ MO_TLSGD,
+
+ /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// See 'ELF Handling for Thread-Local Storage' for more details.
+ /// SYMBOL_LABEL @GOTTPOFF
+ MO_GOTTPOFF,
+
+ /// MO_INDNTPOFF - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// See 'ELF Handling for Thread-Local Storage' for more details.
+ /// SYMBOL_LABEL @INDNTPOFF
+ MO_INDNTPOFF,
+
+ /// MO_TPOFF - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// See 'ELF Handling for Thread-Local Storage' for more details.
+ /// SYMBOL_LABEL @TPOFF
+ MO_TPOFF,
+
+ /// MO_NTPOFF - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// See 'ELF Handling for Thread-Local Storage' for more details.
+ /// SYMBOL_LABEL @NTPOFF
+ MO_NTPOFF,
+
+ /// MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the
+ /// reference is actually to the "__imp_FOO" symbol. This is used for
+ /// dllimport linkage on windows.
+ MO_DLLIMPORT,
+
+ /// MO_DARWIN_STUB - On a symbol operand "FOO", this indicates that the
+ /// reference is actually to the "FOO$stub" symbol. This is used for calls
+ /// and jumps to external functions on Tiger and earlier.
+ MO_DARWIN_STUB,
+
+ /// MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the
+ /// reference is actually to the "FOO$non_lazy_ptr" symbol, which is a
+ /// non-PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
+ MO_DARWIN_NONLAZY,
+
+ /// MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates
+ /// that the reference is actually to "FOO$non_lazy_ptr - PICBASE", which is
+ /// a PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
+ MO_DARWIN_NONLAZY_PIC_BASE,
+
+ /// MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this
+ /// indicates that the reference is actually to "FOO$non_lazy_ptr -PICBASE",
+ /// which is a PIC-base-relative reference to a hidden dyld lazy pointer
+ /// stub.
+ MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE,
+
+ /// MO_TLVP - On a symbol operand this indicates that the immediate is
+ /// some TLS offset.
+ ///
+ /// This is the TLS offset for the Darwin TLS mechanism.
+ MO_TLVP,
+
+ /// MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate
+ /// is some TLS offset from the picbase.
+ ///
+ /// This is the 32-bit TLS offset for Darwin TLS in PIC mode.
+ MO_TLVP_PIC_BASE
+ };
+
+ enum {
+ //===------------------------------------------------------------------===//
+ // Instruction encodings. These are the standard/most common forms for X86
+ // instructions.
+ //
+
+ // PseudoFrm - This represents an instruction that is a pseudo instruction
+ // or one that has not been implemented yet. It is illegal to code generate
+ // it, but tolerated for intermediate implementation stages.
+ Pseudo = 0,
+
+ /// Raw - This form is for instructions that don't have any operands, so
+ /// they are just a fixed opcode value, like 'leave'.
+ RawFrm = 1,
+
+ /// AddRegFrm - This form is used for instructions like 'push r32' that have
+ /// their one register operand added to their opcode.
+ AddRegFrm = 2,
+
+ /// MRMDestReg - This form is used for instructions that use the Mod/RM byte
+ /// to specify a destination, which in this case is a register.
+ ///
+ MRMDestReg = 3,
+
+ /// MRMDestMem - This form is used for instructions that use the Mod/RM byte
+ /// to specify a destination, which in this case is memory.
+ ///
+ MRMDestMem = 4,
+
+ /// MRMSrcReg - This form is used for instructions that use the Mod/RM byte
+ /// to specify a source, which in this case is a register.
+ ///
+ MRMSrcReg = 5,
+
+ /// MRMSrcMem - This form is used for instructions that use the Mod/RM byte
+ /// to specify a source, which in this case is memory.
+ ///
+ MRMSrcMem = 6,
+
+ /// MRM[0-7][rm] - These forms are used to represent instructions that use
+ /// a Mod/RM byte, and use the middle field to hold extended opcode
+ /// information. In the intel manual these are represented as /0, /1, ...
+ ///
+
+ // First, instructions that operate on a register r/m operand...
+ MRM0r = 16, MRM1r = 17, MRM2r = 18, MRM3r = 19, // Format /0 /1 /2 /3
+ MRM4r = 20, MRM5r = 21, MRM6r = 22, MRM7r = 23, // Format /4 /5 /6 /7
+
+ // Next, instructions that operate on a memory r/m operand...
+ MRM0m = 24, MRM1m = 25, MRM2m = 26, MRM3m = 27, // Format /0 /1 /2 /3
+ MRM4m = 28, MRM5m = 29, MRM6m = 30, MRM7m = 31, // Format /4 /5 /6 /7
+
+ // MRMInitReg - This form is used for instructions whose source and
+ // destinations are the same register.
+ MRMInitReg = 32,
+
+ //// MRM_C1 - A mod/rm byte of exactly 0xC1.
+ MRM_C1 = 33,
+ MRM_C2 = 34,
+ MRM_C3 = 35,
+ MRM_C4 = 36,
+ MRM_C8 = 37,
+ MRM_C9 = 38,
+ MRM_E8 = 39,
+ MRM_F0 = 40,
+ MRM_F8 = 41,
+ MRM_F9 = 42,
+ MRM_D0 = 45,
+ MRM_D1 = 46,
+
+ /// RawFrmImm8 - This is used for the ENTER instruction, which has two
+ /// immediates, the first of which is a 16-bit immediate (specified by
+ /// the imm encoding) and the second is a 8-bit fixed value.
+ RawFrmImm8 = 43,
+
+ /// RawFrmImm16 - This is used for CALL FAR instructions, which have two
+ /// immediates, the first of which is a 16 or 32-bit immediate (specified by
+ /// the imm encoding) and the second is a 16-bit fixed value. In the AMD
+ /// manual, this operand is described as pntr16:32 and pntr16:16
+ RawFrmImm16 = 44,
+
+ FormMask = 63,
+
+ //===------------------------------------------------------------------===//
+ // Actual flags...
+
+ // OpSize - Set if this instruction requires an operand size prefix (0x66),
+ // which most often indicates that the instruction operates on 16 bit data
+ // instead of 32 bit data.
+ OpSize = 1 << 6,
+
+ // AsSize - Set if this instruction requires an operand size prefix (0x67),
+ // which most often indicates that the instruction address 16 bit address
+ // instead of 32 bit address (or 32 bit address in 64 bit mode).
+ AdSize = 1 << 7,
+
+ //===------------------------------------------------------------------===//
+ // Op0Mask - There are several prefix bytes that are used to form two byte
+ // opcodes. These are currently 0x0F, 0xF3, and 0xD8-0xDF. This mask is
+ // used to obtain the setting of this field. If no bits in this field is
+ // set, there is no prefix byte for obtaining a multibyte opcode.
+ //
+ Op0Shift = 8,
+ Op0Mask = 0x1F << Op0Shift,
+
+ // TB - TwoByte - Set if this instruction has a two byte opcode, which
+ // starts with a 0x0F byte before the real opcode.
+ TB = 1 << Op0Shift,
+
+ // REP - The 0xF3 prefix byte indicating repetition of the following
+ // instruction.
+ REP = 2 << Op0Shift,
+
+ // D8-DF - These escape opcodes are used by the floating point unit. These
+ // values must remain sequential.
+ D8 = 3 << Op0Shift, D9 = 4 << Op0Shift,
+ DA = 5 << Op0Shift, DB = 6 << Op0Shift,
+ DC = 7 << Op0Shift, DD = 8 << Op0Shift,
+ DE = 9 << Op0Shift, DF = 10 << Op0Shift,
+
+ // XS, XD - These prefix codes are for single and double precision scalar
+ // floating point operations performed in the SSE registers.
+ XD = 11 << Op0Shift, XS = 12 << Op0Shift,
+
+ // T8, TA, A6, A7 - Prefix after the 0x0F prefix.
+ T8 = 13 << Op0Shift, TA = 14 << Op0Shift,
+ A6 = 15 << Op0Shift, A7 = 16 << Op0Shift,
+
+ // TF - Prefix before and after 0x0F
+ TF = 17 << Op0Shift,
+
+ //===------------------------------------------------------------------===//
+ // REX_W - REX prefixes are instruction prefixes used in 64-bit mode.
+ // They are used to specify GPRs and SSE registers, 64-bit operand size,
+ // etc. We only cares about REX.W and REX.R bits and only the former is
+ // statically determined.
+ //
+ REXShift = Op0Shift + 5,
+ REX_W = 1 << REXShift,
+
+ //===------------------------------------------------------------------===//
+ // This three-bit field describes the size of an immediate operand. Zero is
+ // unused so that we can tell if we forgot to set a value.
+ ImmShift = REXShift + 1,
+ ImmMask = 7 << ImmShift,
+ Imm8 = 1 << ImmShift,
+ Imm8PCRel = 2 << ImmShift,
+ Imm16 = 3 << ImmShift,
+ Imm16PCRel = 4 << ImmShift,
+ Imm32 = 5 << ImmShift,
+ Imm32PCRel = 6 << ImmShift,
+ Imm64 = 7 << ImmShift,
+
+ //===------------------------------------------------------------------===//
+ // FP Instruction Classification... Zero is non-fp instruction.
+
+ // FPTypeMask - Mask for all of the FP types...
+ FPTypeShift = ImmShift + 3,
+ FPTypeMask = 7 << FPTypeShift,
+
+ // NotFP - The default, set for instructions that do not use FP registers.
+ NotFP = 0 << FPTypeShift,
+
+ // ZeroArgFP - 0 arg FP instruction which implicitly pushes ST(0), f.e. fld0
+ ZeroArgFP = 1 << FPTypeShift,
+
+ // OneArgFP - 1 arg FP instructions which implicitly read ST(0), such as fst
+ OneArgFP = 2 << FPTypeShift,
+
+ // OneArgFPRW - 1 arg FP instruction which implicitly read ST(0) and write a
+ // result back to ST(0). For example, fcos, fsqrt, etc.
+ //
+ OneArgFPRW = 3 << FPTypeShift,
+
+ // TwoArgFP - 2 arg FP instructions which implicitly read ST(0), and an
+ // explicit argument, storing the result to either ST(0) or the implicit
+ // argument. For example: fadd, fsub, fmul, etc...
+ TwoArgFP = 4 << FPTypeShift,
+
+ // CompareFP - 2 arg FP instructions which implicitly read ST(0) and an
+ // explicit argument, but have no destination. Example: fucom, fucomi, ...
+ CompareFP = 5 << FPTypeShift,
+
+ // CondMovFP - "2 operand" floating point conditional move instructions.
+ CondMovFP = 6 << FPTypeShift,
+
+ // SpecialFP - Special instruction forms. Dispatch by opcode explicitly.
+ SpecialFP = 7 << FPTypeShift,
+
+ // Lock prefix
+ LOCKShift = FPTypeShift + 3,
+ LOCK = 1 << LOCKShift,
+
+ // Segment override prefixes. Currently we just need ability to address
+ // stuff in gs and fs segments.
+ SegOvrShift = LOCKShift + 1,
+ SegOvrMask = 3 << SegOvrShift,
+ FS = 1 << SegOvrShift,
+ GS = 2 << SegOvrShift,
+
+ // Execution domain for SSE instructions in bits 23, 24.
+ // 0 in bits 23-24 means normal, non-SSE instruction.
+ SSEDomainShift = SegOvrShift + 2,
+
+ OpcodeShift = SSEDomainShift + 2,
+
+ //===------------------------------------------------------------------===//
+ /// VEX - The opcode prefix used by AVX instructions
+ VEXShift = OpcodeShift + 8,
+ VEX = 1U << 0,
+
+ /// VEX_W - Has a opcode specific functionality, but is used in the same
+ /// way as REX_W is for regular SSE instructions.
+ VEX_W = 1U << 1,
+
+ /// VEX_4V - Used to specify an additional AVX/SSE register. Several 2
+ /// address instructions in SSE are represented as 3 address ones in AVX
+ /// and the additional register is encoded in VEX_VVVV prefix.
+ VEX_4V = 1U << 2,
+
+ /// VEX_I8IMM - Specifies that the last register used in a AVX instruction,
+ /// must be encoded in the i8 immediate field. This usually happens in
+ /// instructions with 4 operands.
+ VEX_I8IMM = 1U << 3,
+
+ /// VEX_L - Stands for a bit in the VEX opcode prefix meaning the current
+ /// instruction uses 256-bit wide registers. This is usually auto detected
+ /// if a VR256 register is used, but some AVX instructions also have this
+ /// field marked when using a f256 memory references.
+ VEX_L = 1U << 4,
+
+ /// Has3DNow0F0FOpcode - This flag indicates that the instruction uses the
+ /// wacky 0x0F 0x0F prefix for 3DNow! instructions. The manual documents
+ /// this as having a 0x0F prefix with a 0x0F opcode, and each instruction
+ /// storing a classifier in the imm8 field. To simplify our implementation,
+ /// we handle this by storeing the classifier in the opcode field and using
+ /// this flag to indicate that the encoder should do the wacky 3DNow! thing.
+ Has3DNow0F0FOpcode = 1U << 5
+ };
+
+ // getBaseOpcodeFor - This function returns the "base" X86 opcode for the
+ // specified machine instruction.
+ //
+ static inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) {
+ return TSFlags >> X86II::OpcodeShift;
+ }
+
+ static inline bool hasImm(uint64_t TSFlags) {
+ return (TSFlags & X86II::ImmMask) != 0;
+ }
+
+ /// getSizeOfImm - Decode the "size of immediate" field from the TSFlags field
+ /// of the specified instruction.
+ static inline unsigned getSizeOfImm(uint64_t TSFlags) {
+ switch (TSFlags & X86II::ImmMask) {
+ default: assert(0 && "Unknown immediate size");
+ case X86II::Imm8:
+ case X86II::Imm8PCRel: return 1;
+ case X86II::Imm16:
+ case X86II::Imm16PCRel: return 2;
+ case X86II::Imm32:
+ case X86II::Imm32PCRel: return 4;
+ case X86II::Imm64: return 8;
+ }
+ }
+
+ /// isImmPCRel - Return true if the immediate of the specified instruction's
+ /// TSFlags indicates that it is pc relative.
+ static inline unsigned isImmPCRel(uint64_t TSFlags) {
+ switch (TSFlags & X86II::ImmMask) {
+ default: assert(0 && "Unknown immediate size");
+ case X86II::Imm8PCRel:
+ case X86II::Imm16PCRel:
+ case X86II::Imm32PCRel:
+ return true;
+ case X86II::Imm8:
+ case X86II::Imm16:
+ case X86II::Imm32:
+ case X86II::Imm64:
+ return false;
+ }
+ }
+
+ /// getMemoryOperandNo - The function returns the MCInst operand # for the
+ /// first field of the memory operand. If the instruction doesn't have a
+ /// memory operand, this returns -1.
+ ///
+ /// Note that this ignores tied operands. If there is a tied register which
+ /// is duplicated in the MCInst (e.g. "EAX = addl EAX, [mem]") it is only
+ /// counted as one operand.
+ ///
+ static inline int getMemoryOperandNo(uint64_t TSFlags) {
+ switch (TSFlags & X86II::FormMask) {
+ case X86II::MRMInitReg: assert(0 && "FIXME: Remove this form");
+ default: assert(0 && "Unknown FormMask value in getMemoryOperandNo!");
+ case X86II::Pseudo:
+ case X86II::RawFrm:
+ case X86II::AddRegFrm:
+ case X86II::MRMDestReg:
+ case X86II::MRMSrcReg:
+ case X86II::RawFrmImm8:
+ case X86II::RawFrmImm16:
+ return -1;
+ case X86II::MRMDestMem:
+ return 0;
+ case X86II::MRMSrcMem: {
+ bool HasVEX_4V = (TSFlags >> X86II::VEXShift) & X86II::VEX_4V;
+ unsigned FirstMemOp = 1;
+ if (HasVEX_4V)
+ ++FirstMemOp;// Skip the register source (which is encoded in VEX_VVVV).
+
+ // FIXME: Maybe lea should have its own form? This is a horrible hack.
+ //if (Opcode == X86::LEA64r || Opcode == X86::LEA64_32r ||
+ // Opcode == X86::LEA16r || Opcode == X86::LEA32r)
+ return FirstMemOp;
+ }
+ case X86II::MRM0r: case X86II::MRM1r:
+ case X86II::MRM2r: case X86II::MRM3r:
+ case X86II::MRM4r: case X86II::MRM5r:
+ case X86II::MRM6r: case X86II::MRM7r:
+ return -1;
+ case X86II::MRM0m: case X86II::MRM1m:
+ case X86II::MRM2m: case X86II::MRM3m:
+ case X86II::MRM4m: case X86II::MRM5m:
+ case X86II::MRM6m: case X86II::MRM7m:
+ return 0;
+ case X86II::MRM_C1:
+ case X86II::MRM_C2:
+ case X86II::MRM_C3:
+ case X86II::MRM_C4:
+ case X86II::MRM_C8:
+ case X86II::MRM_C9:
+ case X86II::MRM_E8:
+ case X86II::MRM_F0:
+ case X86II::MRM_F8:
+ case X86II::MRM_F9:
+ case X86II::MRM_D0:
+ case X86II::MRM_D1:
+ return -1;
+ }
+ }
+
+ /// isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or
+ /// higher) register? e.g. r8, xmm8, xmm13, etc.
+ static inline bool isX86_64ExtendedReg(unsigned RegNo) {
+ switch (RegNo) {
+ default: break;
+ case X86::R8: case X86::R9: case X86::R10: case X86::R11:
+ case X86::R12: case X86::R13: case X86::R14: case X86::R15:
+ case X86::R8D: case X86::R9D: case X86::R10D: case X86::R11D:
+ case X86::R12D: case X86::R13D: case X86::R14D: case X86::R15D:
+ case X86::R8W: case X86::R9W: case X86::R10W: case X86::R11W:
+ case X86::R12W: case X86::R13W: case X86::R14W: case X86::R15W:
+ case X86::R8B: case X86::R9B: case X86::R10B: case X86::R11B:
+ case X86::R12B: case X86::R13B: case X86::R14B: case X86::R15B:
+ case X86::XMM8: case X86::XMM9: case X86::XMM10: case X86::XMM11:
+ case X86::XMM12: case X86::XMM13: case X86::XMM14: case X86::XMM15:
+ case X86::YMM8: case X86::YMM9: case X86::YMM10: case X86::YMM11:
+ case X86::YMM12: case X86::YMM13: case X86::YMM14: case X86::YMM15:
+ case X86::CR8: case X86::CR9: case X86::CR10: case X86::CR11:
+ case X86::CR12: case X86::CR13: case X86::CR14: case X86::CR15:
+ return true;
+ }
+ return false;
+ }
+
+ static inline bool isX86_64NonExtLowByteReg(unsigned reg) {
+ return (reg == X86::SPL || reg == X86::BPL ||
+ reg == X86::SIL || reg == X86::DIL);
+ }
+}
+
+} // end namespace llvm;
+
+#endif
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h Mon Jul 25 13:43:53 2011
@@ -17,6 +17,9 @@
#include
namespace llvm {
+class MCCodeEmitter;
+class MCContext;
+class MCInstrInfo;
class MCRegisterInfo;
class MCSubtargetInfo;
class Target;
@@ -63,6 +66,11 @@
StringRef FS);
}
+MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,
+ const MCSubtargetInfo &STI,
+ MCContext &Ctx);
+
+
} // End llvm namespace
Modified: llvm/trunk/lib/Target/X86/X86.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86.h (original)
+++ llvm/trunk/lib/Target/X86/X86.h Mon Jul 25 13:43:53 2011
@@ -15,6 +15,7 @@
#ifndef TARGET_X86_H
#define TARGET_X86_H
+#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Target/TargetMachine.h"
@@ -60,10 +61,6 @@
FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM,
JITCodeEmitter &JCE);
-MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,
- const MCSubtargetInfo &STI,
- MCContext &Ctx);
-
TargetAsmBackend *createX86_32AsmBackend(const Target &, const std::string &);
TargetAsmBackend *createX86_64AsmBackend(const Target &, const std::string &);
Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Mon Jul 25 13:43:53 2011
@@ -9,7 +9,7 @@
#include "llvm/MC/TargetAsmBackend.h"
#include "X86.h"
-#include "X86FixupKinds.h"
+#include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCELFObjectWriter.h"
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Jul 25 13:43:53 2011
@@ -167,7 +167,7 @@
const MachineOperand& MO = MI.getOperand(i);
if (MO.isReg()) {
unsigned Reg = MO.getReg();
- if (X86InstrInfo::isX86_64NonExtLowByteReg(Reg))
+ if (X86II::isX86_64NonExtLowByteReg(Reg))
REX |= 0x40;
}
}
Removed: llvm/trunk/lib/Target/X86/X86FixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FixupKinds.h?rev=135929&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FixupKinds.h (original)
+++ llvm/trunk/lib/Target/X86/X86FixupKinds.h (removed)
@@ -1,33 +0,0 @@
-//===-- X86/X86FixupKinds.h - X86 Specific Fixup Entries --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_X86_X86FIXUPKINDS_H
-#define LLVM_X86_X86FIXUPKINDS_H
-
-#include "llvm/MC/MCFixup.h"
-
-namespace llvm {
-namespace X86 {
-enum Fixups {
- reloc_riprel_4byte = FirstTargetFixupKind, // 32-bit rip-relative
- reloc_riprel_4byte_movq_load, // 32-bit rip-relative in movq
- reloc_signed_4byte, // 32-bit signed. Unlike FK_Data_4
- // this will be sign extended at
- // runtime.
- reloc_global_offset_table, // 32-bit, relative to the start
- // of the instruction. Used only
- // for _GLOBAL_OFFSET_TABLE_.
- // Marker
- LastTargetFixupKind,
- NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
-};
-}
-}
-
-#endif
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jul 25 13:43:53 2011
@@ -3013,31 +3013,6 @@
RC == &X86::RFP64RegClass || RC == &X86::RFP80RegClass);
}
-
-/// isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or higher)
-/// register? e.g. r8, xmm8, xmm13, etc.
-bool X86InstrInfo::isX86_64ExtendedReg(unsigned RegNo) {
- switch (RegNo) {
- default: break;
- case X86::R8: case X86::R9: case X86::R10: case X86::R11:
- case X86::R12: case X86::R13: case X86::R14: case X86::R15:
- case X86::R8D: case X86::R9D: case X86::R10D: case X86::R11D:
- case X86::R12D: case X86::R13D: case X86::R14D: case X86::R15D:
- case X86::R8W: case X86::R9W: case X86::R10W: case X86::R11W:
- case X86::R12W: case X86::R13W: case X86::R14W: case X86::R15W:
- case X86::R8B: case X86::R9B: case X86::R10B: case X86::R11B:
- case X86::R12B: case X86::R13B: case X86::R14B: case X86::R15B:
- case X86::XMM8: case X86::XMM9: case X86::XMM10: case X86::XMM11:
- case X86::XMM12: case X86::XMM13: case X86::XMM14: case X86::XMM15:
- case X86::YMM8: case X86::YMM9: case X86::YMM10: case X86::YMM11:
- case X86::YMM12: case X86::YMM13: case X86::YMM14: case X86::YMM15:
- case X86::CR8: case X86::CR9: case X86::CR10: case X86::CR11:
- case X86::CR12: case X86::CR13: case X86::CR14: case X86::CR15:
- return true;
- }
- return false;
-}
-
/// getGlobalBaseReg - Return a virtual register initialized with the
/// the global base register value. Output instructions required to
/// initialize the register in the function entry block, if necessary.
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Jul 25 13:43:53 2011
@@ -27,24 +27,6 @@
class X86TargetMachine;
namespace X86 {
- // Enums for memory operand decoding. Each memory operand is represented with
- // a 5 operand sequence in the form:
- // [BaseReg, ScaleAmt, IndexReg, Disp, Segment]
- // These enums help decode this.
- enum {
- AddrBaseReg = 0,
- AddrScaleAmt = 1,
- AddrIndexReg = 2,
- AddrDisp = 3,
-
- /// AddrSegmentReg - The operand # of the segment in the memory operand.
- AddrSegmentReg = 4,
-
- /// AddrNumOperands - Total number of operands in a memory reference.
- AddrNumOperands = 5
- };
-
-
// X86 specific condition code. These correspond to X86_*_COND in
// X86InstrInfo.td. They must be kept in synch.
enum CondCode {
@@ -82,133 +64,8 @@
/// GetOppositeBranchCondition - Return the inverse of the specified cond,
/// e.g. turning COND_E to COND_NE.
CondCode GetOppositeBranchCondition(X86::CondCode CC);
+} // end namespace X86;
-}
-
-/// X86II - This namespace holds all of the target specific flags that
-/// instruction info tracks.
-///
-namespace X86II {
- /// Target Operand Flag enum.
- enum TOF {
- //===------------------------------------------------------------------===//
- // X86 Specific MachineOperand flags.
-
- MO_NO_FLAG,
-
- /// MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a
- /// relocation of:
- /// SYMBOL_LABEL + [. - PICBASELABEL]
- MO_GOT_ABSOLUTE_ADDRESS,
-
- /// MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the
- /// immediate should get the value of the symbol minus the PIC base label:
- /// SYMBOL_LABEL - PICBASELABEL
- MO_PIC_BASE_OFFSET,
-
- /// MO_GOT - On a symbol operand this indicates that the immediate is the
- /// offset to the GOT entry for the symbol name from the base of the GOT.
- ///
- /// See the X86-64 ELF ABI supplement for more details.
- /// SYMBOL_LABEL @GOT
- MO_GOT,
-
- /// MO_GOTOFF - On a symbol operand this indicates that the immediate is
- /// the offset to the location of the symbol name from the base of the GOT.
- ///
- /// See the X86-64 ELF ABI supplement for more details.
- /// SYMBOL_LABEL @GOTOFF
- MO_GOTOFF,
-
- /// MO_GOTPCREL - On a symbol operand this indicates that the immediate is
- /// offset to the GOT entry for the symbol name from the current code
- /// location.
- ///
- /// See the X86-64 ELF ABI supplement for more details.
- /// SYMBOL_LABEL @GOTPCREL
- MO_GOTPCREL,
-
- /// MO_PLT - On a symbol operand this indicates that the immediate is
- /// offset to the PLT entry of symbol name from the current code location.
- ///
- /// See the X86-64 ELF ABI supplement for more details.
- /// SYMBOL_LABEL @PLT
- MO_PLT,
-
- /// MO_TLSGD - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// See 'ELF Handling for Thread-Local Storage' for more details.
- /// SYMBOL_LABEL @TLSGD
- MO_TLSGD,
-
- /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// See 'ELF Handling for Thread-Local Storage' for more details.
- /// SYMBOL_LABEL @GOTTPOFF
- MO_GOTTPOFF,
-
- /// MO_INDNTPOFF - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// See 'ELF Handling for Thread-Local Storage' for more details.
- /// SYMBOL_LABEL @INDNTPOFF
- MO_INDNTPOFF,
-
- /// MO_TPOFF - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// See 'ELF Handling for Thread-Local Storage' for more details.
- /// SYMBOL_LABEL @TPOFF
- MO_TPOFF,
-
- /// MO_NTPOFF - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// See 'ELF Handling for Thread-Local Storage' for more details.
- /// SYMBOL_LABEL @NTPOFF
- MO_NTPOFF,
-
- /// MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the
- /// reference is actually to the "__imp_FOO" symbol. This is used for
- /// dllimport linkage on windows.
- MO_DLLIMPORT,
-
- /// MO_DARWIN_STUB - On a symbol operand "FOO", this indicates that the
- /// reference is actually to the "FOO$stub" symbol. This is used for calls
- /// and jumps to external functions on Tiger and earlier.
- MO_DARWIN_STUB,
-
- /// MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the
- /// reference is actually to the "FOO$non_lazy_ptr" symbol, which is a
- /// non-PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
- MO_DARWIN_NONLAZY,
-
- /// MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates
- /// that the reference is actually to "FOO$non_lazy_ptr - PICBASE", which is
- /// a PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
- MO_DARWIN_NONLAZY_PIC_BASE,
-
- /// MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this
- /// indicates that the reference is actually to "FOO$non_lazy_ptr -PICBASE",
- /// which is a PIC-base-relative reference to a hidden dyld lazy pointer
- /// stub.
- MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE,
-
- /// MO_TLVP - On a symbol operand this indicates that the immediate is
- /// some TLS offset.
- ///
- /// This is the TLS offset for the Darwin TLS mechanism.
- MO_TLVP,
-
- /// MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate
- /// is some TLS offset from the picbase.
- ///
- /// This is the 32-bit TLS offset for Darwin TLS in PIC mode.
- MO_TLVP_PIC_BASE
- };
-}
/// isGlobalStubReference - Return true if the specified TargetFlag operand is
/// a reference to a stub for a global, not the global itself.
@@ -243,353 +100,6 @@
}
}
-/// X86II - This namespace holds all of the target specific flags that
-/// instruction info tracks.
-///
-namespace X86II {
- enum {
- //===------------------------------------------------------------------===//
- // Instruction encodings. These are the standard/most common forms for X86
- // instructions.
- //
-
- // PseudoFrm - This represents an instruction that is a pseudo instruction
- // or one that has not been implemented yet. It is illegal to code generate
- // it, but tolerated for intermediate implementation stages.
- Pseudo = 0,
-
- /// Raw - This form is for instructions that don't have any operands, so
- /// they are just a fixed opcode value, like 'leave'.
- RawFrm = 1,
-
- /// AddRegFrm - This form is used for instructions like 'push r32' that have
- /// their one register operand added to their opcode.
- AddRegFrm = 2,
-
- /// MRMDestReg - This form is used for instructions that use the Mod/RM byte
- /// to specify a destination, which in this case is a register.
- ///
- MRMDestReg = 3,
-
- /// MRMDestMem - This form is used for instructions that use the Mod/RM byte
- /// to specify a destination, which in this case is memory.
- ///
- MRMDestMem = 4,
-
- /// MRMSrcReg - This form is used for instructions that use the Mod/RM byte
- /// to specify a source, which in this case is a register.
- ///
- MRMSrcReg = 5,
-
- /// MRMSrcMem - This form is used for instructions that use the Mod/RM byte
- /// to specify a source, which in this case is memory.
- ///
- MRMSrcMem = 6,
-
- /// MRM[0-7][rm] - These forms are used to represent instructions that use
- /// a Mod/RM byte, and use the middle field to hold extended opcode
- /// information. In the intel manual these are represented as /0, /1, ...
- ///
-
- // First, instructions that operate on a register r/m operand...
- MRM0r = 16, MRM1r = 17, MRM2r = 18, MRM3r = 19, // Format /0 /1 /2 /3
- MRM4r = 20, MRM5r = 21, MRM6r = 22, MRM7r = 23, // Format /4 /5 /6 /7
-
- // Next, instructions that operate on a memory r/m operand...
- MRM0m = 24, MRM1m = 25, MRM2m = 26, MRM3m = 27, // Format /0 /1 /2 /3
- MRM4m = 28, MRM5m = 29, MRM6m = 30, MRM7m = 31, // Format /4 /5 /6 /7
-
- // MRMInitReg - This form is used for instructions whose source and
- // destinations are the same register.
- MRMInitReg = 32,
-
- //// MRM_C1 - A mod/rm byte of exactly 0xC1.
- MRM_C1 = 33,
- MRM_C2 = 34,
- MRM_C3 = 35,
- MRM_C4 = 36,
- MRM_C8 = 37,
- MRM_C9 = 38,
- MRM_E8 = 39,
- MRM_F0 = 40,
- MRM_F8 = 41,
- MRM_F9 = 42,
- MRM_D0 = 45,
- MRM_D1 = 46,
-
- /// RawFrmImm8 - This is used for the ENTER instruction, which has two
- /// immediates, the first of which is a 16-bit immediate (specified by
- /// the imm encoding) and the second is a 8-bit fixed value.
- RawFrmImm8 = 43,
-
- /// RawFrmImm16 - This is used for CALL FAR instructions, which have two
- /// immediates, the first of which is a 16 or 32-bit immediate (specified by
- /// the imm encoding) and the second is a 16-bit fixed value. In the AMD
- /// manual, this operand is described as pntr16:32 and pntr16:16
- RawFrmImm16 = 44,
-
- FormMask = 63,
-
- //===------------------------------------------------------------------===//
- // Actual flags...
-
- // OpSize - Set if this instruction requires an operand size prefix (0x66),
- // which most often indicates that the instruction operates on 16 bit data
- // instead of 32 bit data.
- OpSize = 1 << 6,
-
- // AsSize - Set if this instruction requires an operand size prefix (0x67),
- // which most often indicates that the instruction address 16 bit address
- // instead of 32 bit address (or 32 bit address in 64 bit mode).
- AdSize = 1 << 7,
-
- //===------------------------------------------------------------------===//
- // Op0Mask - There are several prefix bytes that are used to form two byte
- // opcodes. These are currently 0x0F, 0xF3, and 0xD8-0xDF. This mask is
- // used to obtain the setting of this field. If no bits in this field is
- // set, there is no prefix byte for obtaining a multibyte opcode.
- //
- Op0Shift = 8,
- Op0Mask = 0x1F << Op0Shift,
-
- // TB - TwoByte - Set if this instruction has a two byte opcode, which
- // starts with a 0x0F byte before the real opcode.
- TB = 1 << Op0Shift,
-
- // REP - The 0xF3 prefix byte indicating repetition of the following
- // instruction.
- REP = 2 << Op0Shift,
-
- // D8-DF - These escape opcodes are used by the floating point unit. These
- // values must remain sequential.
- D8 = 3 << Op0Shift, D9 = 4 << Op0Shift,
- DA = 5 << Op0Shift, DB = 6 << Op0Shift,
- DC = 7 << Op0Shift, DD = 8 << Op0Shift,
- DE = 9 << Op0Shift, DF = 10 << Op0Shift,
-
- // XS, XD - These prefix codes are for single and double precision scalar
- // floating point operations performed in the SSE registers.
- XD = 11 << Op0Shift, XS = 12 << Op0Shift,
-
- // T8, TA, A6, A7 - Prefix after the 0x0F prefix.
- T8 = 13 << Op0Shift, TA = 14 << Op0Shift,
- A6 = 15 << Op0Shift, A7 = 16 << Op0Shift,
-
- // TF - Prefix before and after 0x0F
- TF = 17 << Op0Shift,
-
- //===------------------------------------------------------------------===//
- // REX_W - REX prefixes are instruction prefixes used in 64-bit mode.
- // They are used to specify GPRs and SSE registers, 64-bit operand size,
- // etc. We only cares about REX.W and REX.R bits and only the former is
- // statically determined.
- //
- REXShift = Op0Shift + 5,
- REX_W = 1 << REXShift,
-
- //===------------------------------------------------------------------===//
- // This three-bit field describes the size of an immediate operand. Zero is
- // unused so that we can tell if we forgot to set a value.
- ImmShift = REXShift + 1,
- ImmMask = 7 << ImmShift,
- Imm8 = 1 << ImmShift,
- Imm8PCRel = 2 << ImmShift,
- Imm16 = 3 << ImmShift,
- Imm16PCRel = 4 << ImmShift,
- Imm32 = 5 << ImmShift,
- Imm32PCRel = 6 << ImmShift,
- Imm64 = 7 << ImmShift,
-
- //===------------------------------------------------------------------===//
- // FP Instruction Classification... Zero is non-fp instruction.
-
- // FPTypeMask - Mask for all of the FP types...
- FPTypeShift = ImmShift + 3,
- FPTypeMask = 7 << FPTypeShift,
-
- // NotFP - The default, set for instructions that do not use FP registers.
- NotFP = 0 << FPTypeShift,
-
- // ZeroArgFP - 0 arg FP instruction which implicitly pushes ST(0), f.e. fld0
- ZeroArgFP = 1 << FPTypeShift,
-
- // OneArgFP - 1 arg FP instructions which implicitly read ST(0), such as fst
- OneArgFP = 2 << FPTypeShift,
-
- // OneArgFPRW - 1 arg FP instruction which implicitly read ST(0) and write a
- // result back to ST(0). For example, fcos, fsqrt, etc.
- //
- OneArgFPRW = 3 << FPTypeShift,
-
- // TwoArgFP - 2 arg FP instructions which implicitly read ST(0), and an
- // explicit argument, storing the result to either ST(0) or the implicit
- // argument. For example: fadd, fsub, fmul, etc...
- TwoArgFP = 4 << FPTypeShift,
-
- // CompareFP - 2 arg FP instructions which implicitly read ST(0) and an
- // explicit argument, but have no destination. Example: fucom, fucomi, ...
- CompareFP = 5 << FPTypeShift,
-
- // CondMovFP - "2 operand" floating point conditional move instructions.
- CondMovFP = 6 << FPTypeShift,
-
- // SpecialFP - Special instruction forms. Dispatch by opcode explicitly.
- SpecialFP = 7 << FPTypeShift,
-
- // Lock prefix
- LOCKShift = FPTypeShift + 3,
- LOCK = 1 << LOCKShift,
-
- // Segment override prefixes. Currently we just need ability to address
- // stuff in gs and fs segments.
- SegOvrShift = LOCKShift + 1,
- SegOvrMask = 3 << SegOvrShift,
- FS = 1 << SegOvrShift,
- GS = 2 << SegOvrShift,
-
- // Execution domain for SSE instructions in bits 23, 24.
- // 0 in bits 23-24 means normal, non-SSE instruction.
- SSEDomainShift = SegOvrShift + 2,
-
- OpcodeShift = SSEDomainShift + 2,
-
- //===------------------------------------------------------------------===//
- /// VEX - The opcode prefix used by AVX instructions
- VEXShift = OpcodeShift + 8,
- VEX = 1U << 0,
-
- /// VEX_W - Has a opcode specific functionality, but is used in the same
- /// way as REX_W is for regular SSE instructions.
- VEX_W = 1U << 1,
-
- /// VEX_4V - Used to specify an additional AVX/SSE register. Several 2
- /// address instructions in SSE are represented as 3 address ones in AVX
- /// and the additional register is encoded in VEX_VVVV prefix.
- VEX_4V = 1U << 2,
-
- /// VEX_I8IMM - Specifies that the last register used in a AVX instruction,
- /// must be encoded in the i8 immediate field. This usually happens in
- /// instructions with 4 operands.
- VEX_I8IMM = 1U << 3,
-
- /// VEX_L - Stands for a bit in the VEX opcode prefix meaning the current
- /// instruction uses 256-bit wide registers. This is usually auto detected
- /// if a VR256 register is used, but some AVX instructions also have this
- /// field marked when using a f256 memory references.
- VEX_L = 1U << 4,
-
- /// Has3DNow0F0FOpcode - This flag indicates that the instruction uses the
- /// wacky 0x0F 0x0F prefix for 3DNow! instructions. The manual documents
- /// this as having a 0x0F prefix with a 0x0F opcode, and each instruction
- /// storing a classifier in the imm8 field. To simplify our implementation,
- /// we handle this by storeing the classifier in the opcode field and using
- /// this flag to indicate that the encoder should do the wacky 3DNow! thing.
- Has3DNow0F0FOpcode = 1U << 5
- };
-
- // getBaseOpcodeFor - This function returns the "base" X86 opcode for the
- // specified machine instruction.
- //
- static inline unsigned char getBaseOpcodeFor(uint64_t TSFlags) {
- return TSFlags >> X86II::OpcodeShift;
- }
-
- static inline bool hasImm(uint64_t TSFlags) {
- return (TSFlags & X86II::ImmMask) != 0;
- }
-
- /// getSizeOfImm - Decode the "size of immediate" field from the TSFlags field
- /// of the specified instruction.
- static inline unsigned getSizeOfImm(uint64_t TSFlags) {
- switch (TSFlags & X86II::ImmMask) {
- default: assert(0 && "Unknown immediate size");
- case X86II::Imm8:
- case X86II::Imm8PCRel: return 1;
- case X86II::Imm16:
- case X86II::Imm16PCRel: return 2;
- case X86II::Imm32:
- case X86II::Imm32PCRel: return 4;
- case X86II::Imm64: return 8;
- }
- }
-
- /// isImmPCRel - Return true if the immediate of the specified instruction's
- /// TSFlags indicates that it is pc relative.
- static inline unsigned isImmPCRel(uint64_t TSFlags) {
- switch (TSFlags & X86II::ImmMask) {
- default: assert(0 && "Unknown immediate size");
- case X86II::Imm8PCRel:
- case X86II::Imm16PCRel:
- case X86II::Imm32PCRel:
- return true;
- case X86II::Imm8:
- case X86II::Imm16:
- case X86II::Imm32:
- case X86II::Imm64:
- return false;
- }
- }
-
- /// getMemoryOperandNo - The function returns the MCInst operand # for the
- /// first field of the memory operand. If the instruction doesn't have a
- /// memory operand, this returns -1.
- ///
- /// Note that this ignores tied operands. If there is a tied register which
- /// is duplicated in the MCInst (e.g. "EAX = addl EAX, [mem]") it is only
- /// counted as one operand.
- ///
- static inline int getMemoryOperandNo(uint64_t TSFlags) {
- switch (TSFlags & X86II::FormMask) {
- case X86II::MRMInitReg: assert(0 && "FIXME: Remove this form");
- default: assert(0 && "Unknown FormMask value in getMemoryOperandNo!");
- case X86II::Pseudo:
- case X86II::RawFrm:
- case X86II::AddRegFrm:
- case X86II::MRMDestReg:
- case X86II::MRMSrcReg:
- case X86II::RawFrmImm8:
- case X86II::RawFrmImm16:
- return -1;
- case X86II::MRMDestMem:
- return 0;
- case X86II::MRMSrcMem: {
- bool HasVEX_4V = (TSFlags >> X86II::VEXShift) & X86II::VEX_4V;
- unsigned FirstMemOp = 1;
- if (HasVEX_4V)
- ++FirstMemOp;// Skip the register source (which is encoded in VEX_VVVV).
-
- // FIXME: Maybe lea should have its own form? This is a horrible hack.
- //if (Opcode == X86::LEA64r || Opcode == X86::LEA64_32r ||
- // Opcode == X86::LEA16r || Opcode == X86::LEA32r)
- return FirstMemOp;
- }
- case X86II::MRM0r: case X86II::MRM1r:
- case X86II::MRM2r: case X86II::MRM3r:
- case X86II::MRM4r: case X86II::MRM5r:
- case X86II::MRM6r: case X86II::MRM7r:
- return -1;
- case X86II::MRM0m: case X86II::MRM1m:
- case X86II::MRM2m: case X86II::MRM3m:
- case X86II::MRM4m: case X86II::MRM5m:
- case X86II::MRM6m: case X86II::MRM7m:
- return 0;
- case X86II::MRM_C1:
- case X86II::MRM_C2:
- case X86II::MRM_C3:
- case X86II::MRM_C4:
- case X86II::MRM_C8:
- case X86II::MRM_C9:
- case X86II::MRM_E8:
- case X86II::MRM_F0:
- case X86II::MRM_F8:
- case X86II::MRM_F9:
- case X86II::MRM_D0:
- case X86II::MRM_D1:
- return -1;
- }
- }
-}
-
inline static bool isScale(const MachineOperand &MO) {
return MO.isImm() &&
(MO.getImm() == 1 || MO.getImm() == 2 ||
@@ -829,20 +339,11 @@
/// instruction that defines the specified register class.
bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const;
- static bool isX86_64NonExtLowByteReg(unsigned reg) {
- return (reg == X86::SPL || reg == X86::BPL ||
- reg == X86::SIL || reg == X86::DIL);
- }
-
static bool isX86_64ExtendedReg(const MachineOperand &MO) {
if (!MO.isReg()) return false;
- return isX86_64ExtendedReg(MO.getReg());
+ return X86II::isX86_64ExtendedReg(MO.getReg());
}
- /// isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or
- /// higher) register? e.g. r8, xmm8, xmm13, etc.
- static bool isX86_64ExtendedReg(unsigned RegNo);
-
/// getGlobalBaseReg - Return a virtual register initialized with the
/// the global base register value. Output instructions required to
/// initialize the register in the function entry block, if necessary.
Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Mon Jul 25 13:43:53 2011
@@ -12,12 +12,14 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "mccodeemitter"
-#include "X86.h"
-#include "X86InstrInfo.h"
-#include "X86FixupKinds.h"
+#include "MCTargetDesc/X86MCTargetDesc.h"
+#include "MCTargetDesc/X86BaseInfo.h"
+#include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/raw_ostream.h"
@@ -153,6 +155,11 @@
return MCFixup::getKindForSize(Size, isPCRel);
}
+namespace llvm {
+ // FIXME: TableGen this?
+ extern MCRegisterClass X86MCRegisterClasses[]; // In X86GenRegisterInfo.inc.
+}
+
/// Is32BitMemOperand - Return true if the specified instruction with a memory
/// operand should emit the 0x67 prefix byte in 64-bit mode due to a 32-bit
/// memory operand. Op specifies the operand # of the memoperand.
@@ -160,8 +167,10 @@
const MCOperand &BaseReg = MI.getOperand(Op+X86::AddrBaseReg);
const MCOperand &IndexReg = MI.getOperand(Op+X86::AddrIndexReg);
- if ((BaseReg.getReg() != 0 && X86::GR32RegClass.contains(BaseReg.getReg())) ||
- (IndexReg.getReg() != 0 && X86::GR32RegClass.contains(IndexReg.getReg())))
+ if ((BaseReg.getReg() != 0 &&
+ X86MCRegisterClasses[X86::GR32RegClassID].contains(BaseReg.getReg())) ||
+ (IndexReg.getReg() != 0 &&
+ X86MCRegisterClasses[X86::GR32RegClassID].contains(IndexReg.getReg())))
return true;
return false;
}
@@ -506,7 +515,7 @@
case X86II::MRMSrcMem:
case X86II::MRMSrcReg:
if (MI.getNumOperands() > CurOp && MI.getOperand(CurOp).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(CurOp).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(CurOp).getReg()))
VEX_R = 0x0;
CurOp++;
@@ -527,11 +536,11 @@
for (; CurOp != NumOps; ++CurOp) {
const MCOperand &MO = MI.getOperand(CurOp);
- if (MO.isReg() && X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ if (MO.isReg() && X86II::isX86_64ExtendedReg(MO.getReg()))
VEX_B = 0x0;
if (!VEX_B && MO.isReg() &&
((TSFlags & X86II::FormMask) == X86II::MRMSrcMem) &&
- X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ X86II::isX86_64ExtendedReg(MO.getReg()))
VEX_X = 0x0;
}
break;
@@ -540,7 +549,7 @@
break;
if (MI.getOperand(CurOp).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(CurOp).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(CurOp).getReg()))
VEX_B = 0;
if (HasVEX_4V)
@@ -550,7 +559,7 @@
for (; CurOp != NumOps; ++CurOp) {
const MCOperand &MO = MI.getOperand(CurOp);
if (MO.isReg() && !HasVEX_4V &&
- X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ X86II::isX86_64ExtendedReg(MO.getReg()))
VEX_R = 0x0;
}
break;
@@ -606,7 +615,7 @@
const MCOperand &MO = MI.getOperand(i);
if (!MO.isReg()) continue;
unsigned Reg = MO.getReg();
- if (!X86InstrInfo::isX86_64NonExtLowByteReg(Reg)) continue;
+ if (!X86II::isX86_64NonExtLowByteReg(Reg)) continue;
// FIXME: The caller of DetermineREXPrefix slaps this prefix onto anything
// that returns non-zero.
REX |= 0x40; // REX fixed encoding prefix
@@ -617,25 +626,25 @@
case X86II::MRMInitReg: assert(0 && "FIXME: Remove this!");
case X86II::MRMSrcReg:
if (MI.getOperand(0).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
REX |= 1 << 2; // set REX.R
i = isTwoAddr ? 2 : 1;
for (; i != NumOps; ++i) {
const MCOperand &MO = MI.getOperand(i);
- if (MO.isReg() && X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ if (MO.isReg() && X86II::isX86_64ExtendedReg(MO.getReg()))
REX |= 1 << 0; // set REX.B
}
break;
case X86II::MRMSrcMem: {
if (MI.getOperand(0).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
REX |= 1 << 2; // set REX.R
unsigned Bit = 0;
i = isTwoAddr ? 2 : 1;
for (; i != NumOps; ++i) {
const MCOperand &MO = MI.getOperand(i);
if (MO.isReg()) {
- if (X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ if (X86II::isX86_64ExtendedReg(MO.getReg()))
REX |= 1 << Bit; // set REX.B (Bit=0) and REX.X (Bit=1)
Bit++;
}
@@ -650,13 +659,13 @@
unsigned e = (isTwoAddr ? X86::AddrNumOperands+1 : X86::AddrNumOperands);
i = isTwoAddr ? 1 : 0;
if (NumOps > e && MI.getOperand(e).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(e).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(e).getReg()))
REX |= 1 << 2; // set REX.R
unsigned Bit = 0;
for (; i != e; ++i) {
const MCOperand &MO = MI.getOperand(i);
if (MO.isReg()) {
- if (X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ if (X86II::isX86_64ExtendedReg(MO.getReg()))
REX |= 1 << Bit; // REX.B (Bit=0) and REX.X (Bit=1)
Bit++;
}
@@ -665,12 +674,12 @@
}
default:
if (MI.getOperand(0).isReg() &&
- X86InstrInfo::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
+ X86II::isX86_64ExtendedReg(MI.getOperand(0).getReg()))
REX |= 1 << 0; // set REX.B
i = isTwoAddr ? 2 : 1;
for (unsigned e = NumOps; i != e; ++i) {
const MCOperand &MO = MI.getOperand(i);
- if (MO.isReg() && X86InstrInfo::isX86_64ExtendedReg(MO.getReg()))
+ if (MO.isReg() && X86II::isX86_64ExtendedReg(MO.getReg()))
REX |= 1 << 2; // set REX.R
}
break;
@@ -1009,7 +1018,7 @@
if ((TSFlags >> X86II::VEXShift) & X86II::VEX_I8IMM) {
const MCOperand &MO = MI.getOperand(CurOp++);
bool IsExtReg =
- X86InstrInfo::isX86_64ExtendedReg(MO.getReg());
+ X86II::isX86_64ExtendedReg(MO.getReg());
unsigned RegNum = (IsExtReg ? (1 << 7) : 0);
RegNum |= GetX86RegNum(MO) << 4;
EmitImmediate(MCOperand::CreateImm(RegNum), 1, FK_Data_1, CurByte, OS,
Modified: llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp?rev=135930&r1=135929&r2=135930&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp Mon Jul 25 13:43:53 2011
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "X86.h"
-#include "X86FixupKinds.h"
+#include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmLayout.h"
From jstaszak at apple.com Mon Jul 25 14:25:40 2011
From: jstaszak at apple.com (Jakub Staszak)
Date: Mon, 25 Jul 2011 19:25:40 -0000
Subject: [llvm-commits] [llvm] r135937 - in /llvm/trunk: include/llvm/
include/llvm/Analysis/ include/llvm/CodeGen/ lib/Analysis/ lib/CodeGen/
Message-ID: <20110725192540.B84F42A6C12C@llvm.org>
Author: kuba
Date: Mon Jul 25 14:25:40 2011
New Revision: 135937
URL: http://llvm.org/viewvc/llvm-project?rev=135937&view=rev
Log:
Rename BlockFrequency to BlockFrequencyInfo and MachineBlockFrequency to
MachineBlockFrequencyInfo.
Added:
llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h
- copied, changed from r135924, llvm/trunk/include/llvm/Analysis/BlockFrequency.h
llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
- copied, changed from r135924, llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h
llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
- copied, changed from r135924, llvm/trunk/lib/Analysis/BlockFrequency.cpp
llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
- copied, changed from r135924, llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp
Removed:
llvm/trunk/include/llvm/Analysis/BlockFrequency.h
llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h
llvm/trunk/lib/Analysis/BlockFrequency.cpp
llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp
Modified:
llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/lib/Analysis/Analysis.cpp
llvm/trunk/lib/Analysis/CMakeLists.txt
llvm/trunk/lib/CodeGen/CMakeLists.txt
llvm/trunk/lib/CodeGen/CodeGen.cpp
Removed: llvm/trunk/include/llvm/Analysis/BlockFrequency.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequency.h?rev=135936&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequency.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequency.h (removed)
@@ -1,53 +0,0 @@
-//========-------- BlockFrequency.h - Block Frequency Analysis -------========//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Loops should be simplified before this analysis.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ANALYSIS_BLOCKFREQUENCY_H
-#define LLVM_ANALYSIS_BLOCKFREQUENCY_H
-
-#include "llvm/Pass.h"
-#include
-
-namespace llvm {
-
-class BranchProbabilityInfo;
-template
-class BlockFrequencyImpl;
-
-/// BlockFrequency pass uses BlockFrequencyImpl implementation to estimate
-/// IR basic block frequencies.
-class BlockFrequency : public FunctionPass {
-
- BlockFrequencyImpl *BFI;
-
-public:
- static char ID;
-
- BlockFrequency();
-
- ~BlockFrequency();
-
- void getAnalysisUsage(AnalysisUsage &AU) const;
-
- bool runOnFunction(Function &F);
-
- /// getblockFreq - Return block frequency. Return 0 if we don't have the
- /// information. Please note that initial frequency is equal to 1024. It means
- /// that we should not rely on the value itself, but only on the comparison to
- /// the other block frequencies. We do this to avoid using of floating points.
- ///
- uint32_t getBlockFreq(BasicBlock *BB);
-};
-
-}
-
-#endif
Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyImpl.h Mon Jul 25 14:25:40 2011
@@ -29,8 +29,8 @@
namespace llvm {
-class BlockFrequency;
-class MachineBlockFrequency;
+class BlockFrequencyInfo;
+class MachineBlockFrequencyInfo;
/// BlockFrequencyImpl implements block frequency algorithm for IR and
/// Machine Instructions. Algorithm starts with value 1024 (START_FREQ)
@@ -263,8 +263,8 @@
}
}
- friend class BlockFrequency;
- friend class MachineBlockFrequency;
+ friend class BlockFrequencyInfo;
+ friend class MachineBlockFrequencyInfo;
void doFunction(FunctionT *fn, BlockProbInfoT *bpi) {
Fn = fn;
Copied: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h (from r135924, llvm/trunk/include/llvm/Analysis/BlockFrequency.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h?p2=llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h&p1=llvm/trunk/include/llvm/Analysis/BlockFrequency.h&r1=135924&r2=135937&rev=135937&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequency.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfo.h Mon Jul 25 14:25:40 2011
@@ -1,4 +1,4 @@
-//========-------- BlockFrequency.h - Block Frequency Analysis -------========//
+//========-------- BlockFrequencyInfo.h - Block Frequency Analysis -------========//
//
// The LLVM Compiler Infrastructure
//
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_ANALYSIS_BLOCKFREQUENCY_H
-#define LLVM_ANALYSIS_BLOCKFREQUENCY_H
+#ifndef LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
+#define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
#include "llvm/Pass.h"
#include
@@ -23,18 +23,18 @@
template
class BlockFrequencyImpl;
-/// BlockFrequency pass uses BlockFrequencyImpl implementation to estimate
+/// BlockFrequencyInfo pass uses BlockFrequencyImpl implementation to estimate
/// IR basic block frequencies.
-class BlockFrequency : public FunctionPass {
+class BlockFrequencyInfo : public FunctionPass {
BlockFrequencyImpl *BFI;
public:
static char ID;
- BlockFrequency();
+ BlockFrequencyInfo();
- ~BlockFrequency();
+ ~BlockFrequencyInfo();
void getAnalysisUsage(AnalysisUsage &AU) const;
Removed: llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h?rev=135936&view=auto
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h (removed)
@@ -1,53 +0,0 @@
-//====----- MachineBlockFrequency.h - MachineBlock Frequency Analysis ----====//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Loops should be simplified before this analysis.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CODEGEN_MACHINEBLOCKFREQUENCY_H
-#define LLVM_CODEGEN_MACHINEBLOCKFREQUENCY_H
-
-#include "llvm/CodeGen/MachineFunctionPass.h"
-#include
-
-namespace llvm {
-
-class MachineBranchProbabilityInfo;
-template
-class BlockFrequencyImpl;
-
-/// MachineBlockFrequency pass uses BlockFrequencyImpl implementation to estimate
-/// machine basic block frequencies.
-class MachineBlockFrequency : public MachineFunctionPass {
-
- BlockFrequencyImpl *MBFI;
-
-public:
- static char ID;
-
- MachineBlockFrequency();
-
- ~MachineBlockFrequency();
-
- void getAnalysisUsage(AnalysisUsage &AU) const;
-
- bool runOnMachineFunction(MachineFunction &F);
-
- /// getblockFreq - Return block frequency. Return 0 if we don't have the
- /// information. Please note that initial frequency is equal to 1024. It means
- /// that we should not rely on the value itself, but only on the comparison to
- /// the other block frequencies. We do this to avoid using of floating points.
- ///
- uint32_t getBlockFreq(MachineBasicBlock *MBB);
-};
-
-}
-
-#endif
Copied: llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h (from r135924, llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h?p2=llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h&p1=llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h&r1=135924&r2=135937&rev=135937&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBlockFrequency.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h Mon Jul 25 14:25:40 2011
@@ -1,4 +1,4 @@
-//====----- MachineBlockFrequency.h - MachineBlock Frequency Analysis ----====//
+//====----- MachineBlockFrequencyInfo.h - MachineBlock Frequency Analysis ----====//
//
// The LLVM Compiler Infrastructure
//
@@ -23,18 +23,18 @@
template
class BlockFrequencyImpl;
-/// MachineBlockFrequency pass uses BlockFrequencyImpl implementation to estimate
+/// MachineBlockFrequencyInfo pass uses BlockFrequencyImpl implementation to estimate
/// machine basic block frequencies.
-class MachineBlockFrequency : public MachineFunctionPass {
+class MachineBlockFrequencyInfo : public MachineFunctionPass {
BlockFrequencyImpl *MBFI;
public:
static char ID;
- MachineBlockFrequency();
+ MachineBlockFrequencyInfo();
- ~MachineBlockFrequency();
+ ~MachineBlockFrequencyInfo();
void getAnalysisUsage(AnalysisUsage &AU) const;
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Mon Jul 25 14:25:40 2011
@@ -65,7 +65,7 @@
void initializeBasicAliasAnalysisPass(PassRegistry&);
void initializeBasicCallGraphPass(PassRegistry&);
void initializeBlockExtractorPassPass(PassRegistry&);
-void initializeBlockFrequencyPass(PassRegistry&);
+void initializeBlockFrequencyInfoPass(PassRegistry&);
void initializeBlockPlacementPass(PassRegistry&);
void initializeBranchProbabilityInfoPass(PassRegistry&);
void initializeBreakCriticalEdgesPass(PassRegistry&);
@@ -145,7 +145,7 @@
void initializeLowerInvokePass(PassRegistry&);
void initializeLowerSetJmpPass(PassRegistry&);
void initializeLowerSwitchPass(PassRegistry&);
-void initializeMachineBlockFrequencyPass(PassRegistry&);
+void initializeMachineBlockFrequencyInfoPass(PassRegistry&);
void initializeMachineBranchProbabilityInfoPass(PassRegistry&);
void initializeMachineCSEPass(PassRegistry&);
void initializeMachineDominatorTreePass(PassRegistry&);
Modified: llvm/trunk/lib/Analysis/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Analysis.cpp (original)
+++ llvm/trunk/lib/Analysis/Analysis.cpp Mon Jul 25 14:25:40 2011
@@ -23,7 +23,7 @@
initializeAliasSetPrinterPass(Registry);
initializeNoAAPass(Registry);
initializeBasicAliasAnalysisPass(Registry);
- initializeBlockFrequencyPass(Registry);
+ initializeBlockFrequencyInfoPass(Registry);
initializeBranchProbabilityInfoPass(Registry);
initializeCFGViewerPass(Registry);
initializeCFGPrinterPass(Registry);
Removed: llvm/trunk/lib/Analysis/BlockFrequency.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequency.cpp?rev=135936&view=auto
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequency.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequency.cpp (removed)
@@ -1,59 +0,0 @@
-//=======-------- BlockFrequency.cpp - Block Frequency Analysis -------=======//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Loops should be simplified before this analysis.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/InitializePasses.h"
-#include "llvm/Analysis/BlockFrequencyImpl.h"
-#include "llvm/Analysis/BlockFrequency.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/Analysis/BranchProbabilityInfo.h"
-
-using namespace llvm;
-
-INITIALIZE_PASS_BEGIN(BlockFrequency, "block-freq", "Block Frequency Analysis",
- true, true)
-INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfo)
-INITIALIZE_PASS_END(BlockFrequency, "block-freq", "Block Frequency Analysis",
- true, true)
-
-char BlockFrequency::ID = 0;
-
-
-BlockFrequency::BlockFrequency() : FunctionPass(ID) {
- initializeBlockFrequencyPass(*PassRegistry::getPassRegistry());
- BFI = new BlockFrequencyImpl();
-}
-
-BlockFrequency::~BlockFrequency() {
- delete BFI;
-}
-
-void BlockFrequency::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired();
- AU.setPreservesAll();
-}
-
-bool BlockFrequency::runOnFunction(Function &F) {
- BranchProbabilityInfo &BPI = getAnalysis();
- BFI->doFunction(&F, &BPI);
- return false;
-}
-
-/// getblockFreq - Return block frequency. Return 0 if we don't have the
-/// information. Please note that initial frequency is equal to 1024. It means
-/// that we should not rely on the value itself, but only on the comparison to
-/// the other block frequencies. We do this to avoid using of floating points.
-///
-uint32_t BlockFrequency::getBlockFreq(BasicBlock *BB) {
- return BFI->getBlockFreq(BB);
-}
Copied: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp (from r135924, llvm/trunk/lib/Analysis/BlockFrequency.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp?p2=llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp&p1=llvm/trunk/lib/Analysis/BlockFrequency.cpp&r1=135924&r2=135937&rev=135937&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequency.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp Mon Jul 25 14:25:40 2011
@@ -1,4 +1,4 @@
-//=======-------- BlockFrequency.cpp - Block Frequency Analysis -------=======//
+//=======-------- BlockFrequencyInfo.cpp - Block Frequency Analysis -------=======//
//
// The LLVM Compiler Infrastructure
//
@@ -13,37 +13,37 @@
#include "llvm/InitializePasses.h"
#include "llvm/Analysis/BlockFrequencyImpl.h"
-#include "llvm/Analysis/BlockFrequency.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
using namespace llvm;
-INITIALIZE_PASS_BEGIN(BlockFrequency, "block-freq", "Block Frequency Analysis",
+INITIALIZE_PASS_BEGIN(BlockFrequencyInfo, "block-freq", "Block Frequency Analysis",
true, true)
INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfo)
-INITIALIZE_PASS_END(BlockFrequency, "block-freq", "Block Frequency Analysis",
+INITIALIZE_PASS_END(BlockFrequencyInfo, "block-freq", "Block Frequency Analysis",
true, true)
-char BlockFrequency::ID = 0;
+char BlockFrequencyInfo::ID = 0;
-BlockFrequency::BlockFrequency() : FunctionPass(ID) {
- initializeBlockFrequencyPass(*PassRegistry::getPassRegistry());
+BlockFrequencyInfo::BlockFrequencyInfo() : FunctionPass(ID) {
+ initializeBlockFrequencyInfoPass(*PassRegistry::getPassRegistry());
BFI = new BlockFrequencyImpl();
}
-BlockFrequency::~BlockFrequency() {
+BlockFrequencyInfo::~BlockFrequencyInfo() {
delete BFI;
}
-void BlockFrequency::getAnalysisUsage(AnalysisUsage &AU) const {
+void BlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired();
AU.setPreservesAll();
}
-bool BlockFrequency::runOnFunction(Function &F) {
+bool BlockFrequencyInfo::runOnFunction(Function &F) {
BranchProbabilityInfo &BPI = getAnalysis();
BFI->doFunction(&F, &BPI);
return false;
@@ -54,6 +54,6 @@
/// that we should not rely on the value itself, but only on the comparison to
/// the other block frequencies. We do this to avoid using of floating points.
///
-uint32_t BlockFrequency::getBlockFreq(BasicBlock *BB) {
+uint32_t BlockFrequencyInfo::getBlockFreq(BasicBlock *BB) {
return BFI->getBlockFreq(BB);
}
Modified: llvm/trunk/lib/Analysis/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CMakeLists.txt (original)
+++ llvm/trunk/lib/Analysis/CMakeLists.txt Mon Jul 25 14:25:40 2011
@@ -6,7 +6,7 @@
AliasSetTracker.cpp
Analysis.cpp
BasicAliasAnalysis.cpp
- BlockFrequency.cpp
+ BlockFrequencyInfo.cpp
BranchProbabilityInfo.cpp
CFGPrinter.cpp
CaptureTracking.cpp
Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/CMakeLists.txt Mon Jul 25 14:25:40 2011
@@ -33,7 +33,7 @@
LocalStackSlotAllocation.cpp
LowerSubregs.cpp
MachineBasicBlock.cpp
- MachineBlockFrequency.cpp
+ MachineBlockFrequencyInfo.cpp
MachineBranchProbabilityInfo.cpp
MachineCSE.cpp
MachineDominators.cpp
Modified: llvm/trunk/lib/CodeGen/CodeGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGen.cpp?rev=135937&r1=135936&r2=135937&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGen.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGen.cpp Mon Jul 25 14:25:40 2011
@@ -27,6 +27,7 @@
initializeLiveIntervalsPass(Registry);
initializeLiveStacksPass(Registry);
initializeLiveVariablesPass(Registry);
+ initializeMachineBlockFrequencyInfoPass(Registry);
initializeMachineCSEPass(Registry);
initializeMachineDominatorTreePass(Registry);
initializeMachineLICMPass(Registry);
Removed: llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp?rev=135936&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp (removed)
@@ -1,60 +0,0 @@
-//====----- MachineBlockFrequency.cpp - Machine Block Frequency Analysis ----====//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Loops should be simplified before this analysis.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/InitializePasses.h"
-#include "llvm/Analysis/BlockFrequencyImpl.h"
-#include "llvm/CodeGen/MachineBlockFrequency.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
-
-using namespace llvm;
-
-INITIALIZE_PASS_BEGIN(MachineBlockFrequency, "machine-block-freq",
- "Machine Block Frequency Analysis", true, true)
-INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo)
-INITIALIZE_PASS_END(MachineBlockFrequency, "machine-block-freq",
- "Machine Block Frequency Analysis", true, true)
-
-char MachineBlockFrequency::ID = 0;
-
-
-MachineBlockFrequency::MachineBlockFrequency() : MachineFunctionPass(ID) {
- initializeMachineBlockFrequencyPass(*PassRegistry::getPassRegistry());
- MBFI = new BlockFrequencyImpl();
-}
-
-MachineBlockFrequency::~MachineBlockFrequency() {
- delete MBFI;
-}
-
-void MachineBlockFrequency::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired();
- AU.setPreservesAll();
- MachineFunctionPass::getAnalysisUsage(AU);
-}
-
-bool MachineBlockFrequency::runOnMachineFunction(MachineFunction &F) {
- MachineBranchProbabilityInfo &MBPI = getAnalysis();
- MBFI->doFunction(&F, &MBPI);
- return false;
-}
-
-/// getblockFreq - Return block frequency. Return 0 if we don't have the
-/// information. Please note that initial frequency is equal to 1024. It means
-/// that we should not rely on the value itself, but only on the comparison to
-/// the other block frequencies. We do this to avoid using of floating points.
-///
-uint32_t MachineBlockFrequency::getBlockFreq(MachineBasicBlock *MBB) {
- return MBFI->getBlockFreq(MBB);
-}
Copied: llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp (from r135924, llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp?p2=llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp&p1=llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp&r1=135924&r2=135937&rev=135937&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockFrequency.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp Mon Jul 25 14:25:40 2011
@@ -1,4 +1,4 @@
-//====----- MachineBlockFrequency.cpp - Machine Block Frequency Analysis ----====//
+//====----- MachineBlockFrequencyInfo.cpp - Machine Block Frequency Analysis ----====//
//
// The LLVM Compiler Infrastructure
//
@@ -13,38 +13,38 @@
#include "llvm/InitializePasses.h"
#include "llvm/Analysis/BlockFrequencyImpl.h"
-#include "llvm/CodeGen/MachineBlockFrequency.h"
+#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
using namespace llvm;
-INITIALIZE_PASS_BEGIN(MachineBlockFrequency, "machine-block-freq",
+INITIALIZE_PASS_BEGIN(MachineBlockFrequencyInfo, "machine-block-freq",
"Machine Block Frequency Analysis", true, true)
INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo)
-INITIALIZE_PASS_END(MachineBlockFrequency, "machine-block-freq",
+INITIALIZE_PASS_END(MachineBlockFrequencyInfo, "machine-block-freq",
"Machine Block Frequency Analysis", true, true)
-char MachineBlockFrequency::ID = 0;
+char MachineBlockFrequencyInfo::ID = 0;
-MachineBlockFrequency::MachineBlockFrequency() : MachineFunctionPass(ID) {
- initializeMachineBlockFrequencyPass(*PassRegistry::getPassRegistry());
+MachineBlockFrequencyInfo::MachineBlockFrequencyInfo() : MachineFunctionPass(ID) {
+ initializeMachineBlockFrequencyInfoPass(*PassRegistry::getPassRegistry());
MBFI = new BlockFrequencyImpl();
}
-MachineBlockFrequency::~MachineBlockFrequency() {
+MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() {
delete MBFI;
}
-void MachineBlockFrequency::getAnalysisUsage(AnalysisUsage &AU) const {
+void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired();
AU.setPreservesAll();
MachineFunctionPass::getAnalysisUsage(AU);
}
-bool MachineBlockFrequency::runOnMachineFunction(MachineFunction &F) {
+bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) {
MachineBranchProbabilityInfo &MBPI = getAnalysis();
MBFI->doFunction(&F, &MBPI);
return false;
@@ -55,6 +55,6 @@
/// that we should not rely on the value itself, but only on the comparison to
/// the other block frequencies. We do this to avoid using of floating points.
///
-uint32_t MachineBlockFrequency::getBlockFreq(MachineBasicBlock *MBB) {
+uint32_t MachineBlockFrequencyInfo::getBlockFreq(MachineBasicBlock *MBB) {
return MBFI->getBlockFreq(MBB);
}
From evan.cheng at apple.com Mon Jul 25 14:33:48 2011
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 25 Jul 2011 19:33:48 -0000
Subject: [llvm-commits] [llvm] r135939 - in /llvm/trunk/lib/Target/X86:
CMakeLists.txt MCTargetDesc/CMakeLists.txt MCTargetDesc/X86AsmBackend.cpp
MCTargetDesc/X86MCCodeEmitter.cpp MCTargetDesc/X86MCTargetDesc.cpp
MCTargetDesc/X86MCTargetDesc.h MCTargetDesc/X86MachObjectWriter.cpp X86.h
X86AsmBackend.cpp X86MCCodeEmitter.cpp X86MachObjectWriter.cpp
X86TargetMachine.cpp
Message-ID: <20110725193349.1900E2A6C12C@llvm.org>
Author: evancheng
Date: Mon Jul 25 14:33:48 2011
New Revision: 135939
URL: http://llvm.org/viewvc/llvm-project?rev=135939&view=rev
Log:
More refactoring.
Added:
llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
- copied, changed from r135930, llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
- copied unchanged from r135930, llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
- copied, changed from r135930, llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp
Removed:
llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp
llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp
Modified:
llvm/trunk/lib/Target/X86/CMakeLists.txt
llvm/trunk/lib/Target/X86/MCTargetDesc/CMakeLists.txt
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
llvm/trunk/lib/Target/X86/X86.h
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/trunk/lib/Target/X86/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/CMakeLists.txt?rev=135939&r1=135938&r2=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/X86/CMakeLists.txt Mon Jul 25 14:33:48 2011
@@ -14,7 +14,6 @@
set(sources
SSEDomainFix.cpp
- X86AsmBackend.cpp
X86AsmPrinter.cpp
X86COFFMachineModuleInfo.cpp
X86CodeEmitter.cpp
@@ -26,8 +25,6 @@
X86ISelLowering.cpp
X86InstrInfo.cpp
X86JITInfo.cpp
- X86MachObjectWriter.cpp
- X86MCCodeEmitter.cpp
X86MCInstLower.cpp
X86RegisterInfo.cpp
X86SelectionDAGInfo.cpp
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/CMakeLists.txt?rev=135939&r1=135938&r2=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/CMakeLists.txt Mon Jul 25 14:33:48 2011
@@ -1,6 +1,9 @@
add_llvm_library(LLVMX86Desc
+ X86AsmBackend.cpp
X86MCTargetDesc.cpp
X86MCAsmInfo.cpp
+ X86MCCodeEmitter.cpp
+ X86MachObjectWriter.cpp
)
# Hack: we need to include 'main' target directory to grab private headers
Copied: llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (from r135930, llvm/trunk/lib/Target/X86/X86AsmBackend.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp?p2=llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp&p1=llvm/trunk/lib/Target/X86/X86AsmBackend.cpp&r1=135930&r2=135939&rev=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp Mon Jul 25 14:33:48 2011
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/MC/TargetAsmBackend.h"
-#include "X86.h"
+#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAssembler.h"
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp?rev=135939&r1=135938&r2=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp Mon Jul 25 14:33:48 2011
@@ -16,6 +16,7 @@
#include "llvm/MC/MachineLocation.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/Triple.h"
@@ -363,6 +364,23 @@
return X;
}
+static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
+ MCContext &Ctx, TargetAsmBackend &TAB,
+ raw_ostream &_OS,
+ MCCodeEmitter *_Emitter,
+ bool RelaxAll,
+ bool NoExecStack) {
+ Triple TheTriple(TT);
+
+ if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
+ return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
+
+ if (TheTriple.isOSWindows())
+ return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
+
+ return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
+}
+
// Force static initialization.
extern "C" void LLVMInitializeX86TargetMC() {
// Register the MC asm info.
@@ -386,4 +404,22 @@
X86_MC::createX86MCSubtargetInfo);
TargetRegistry::RegisterMCSubtargetInfo(TheX86_64Target,
X86_MC::createX86MCSubtargetInfo);
+
+ // Register the code emitter.
+ TargetRegistry::RegisterCodeEmitter(TheX86_32Target,
+ createX86MCCodeEmitter);
+ TargetRegistry::RegisterCodeEmitter(TheX86_64Target,
+ createX86MCCodeEmitter);
+
+ // Register the asm backend.
+ TargetRegistry::RegisterAsmBackend(TheX86_32Target,
+ createX86_32AsmBackend);
+ TargetRegistry::RegisterAsmBackend(TheX86_64Target,
+ createX86_64AsmBackend);
+
+ // Register the object streamer.
+ TargetRegistry::RegisterObjectStreamer(TheX86_32Target,
+ createMCStreamer);
+ TargetRegistry::RegisterObjectStreamer(TheX86_64Target,
+ createMCStreamer);
}
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h?rev=135939&r1=135938&r2=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h Mon Jul 25 14:33:48 2011
@@ -20,10 +20,13 @@
class MCCodeEmitter;
class MCContext;
class MCInstrInfo;
+class MCObjectWriter;
class MCRegisterInfo;
class MCSubtargetInfo;
class Target;
+class TargetAsmBackend;
class StringRef;
+class raw_ostream;
extern Target TheX86_32Target, TheX86_64Target;
@@ -70,6 +73,14 @@
const MCSubtargetInfo &STI,
MCContext &Ctx);
+TargetAsmBackend *createX86_32AsmBackend(const Target &, const std::string &);
+TargetAsmBackend *createX86_64AsmBackend(const Target &, const std::string &);
+
+/// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
+MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,
+ bool Is64Bit,
+ uint32_t CPUType,
+ uint32_t CPUSubtype);
} // End llvm namespace
Copied: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (from r135930, llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp?p2=llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp&p1=llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp&r1=135930&r2=135939&rev=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Mon Jul 25 14:33:48 2011
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "X86.h"
#include "MCTargetDesc/X86FixupKinds.h"
-#include "llvm/ADT/Twine.h"
+#include "MCTargetDesc/X86MCTargetDesc.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCValue.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Object/MachOFormat.h"
Modified: llvm/trunk/lib/Target/X86/X86.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=135939&r1=135938&r2=135939&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86.h (original)
+++ llvm/trunk/lib/Target/X86/X86.h Mon Jul 25 14:33:48 2011
@@ -61,9 +61,6 @@
FunctionPass *createX86JITCodeEmitterPass(X86TargetMachine &TM,
JITCodeEmitter &JCE);
-TargetAsmBackend *createX86_32AsmBackend(const Target &, const std::string &);
-TargetAsmBackend *createX86_64AsmBackend(const Target &, const std::string &);
-
/// createX86EmitCodeToMemory - Returns a pass that converts a register
/// allocated function into raw machine code in a dynamically
/// allocated chunk of memory.
@@ -76,13 +73,6 @@
///
FunctionPass *createX86MaxStackAlignmentHeuristicPass();
-
-/// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
-MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,
- bool Is64Bit,
- uint32_t CPUType,
- uint32_t CPUSubtype);
-
} // End llvm namespace
#endif
Removed: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=135938&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (removed)
@@ -1,452 +0,0 @@
-//===-- X86AsmBackend.cpp - X86 Assembler Backend -------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/MC/TargetAsmBackend.h"
-#include "X86.h"
-#include "MCTargetDesc/X86FixupKinds.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/MC/MCAssembler.h"
-#include "llvm/MC/MCELFObjectWriter.h"
-#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCMachObjectWriter.h"
-#include "llvm/MC/MCObjectWriter.h"
-#include "llvm/MC/MCSectionCOFF.h"
-#include "llvm/MC/MCSectionELF.h"
-#include "llvm/MC/MCSectionMachO.h"
-#include "llvm/Object/MachOFormat.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ELF.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetRegistry.h"
-using namespace llvm;
-
-// Option to allow disabling arithmetic relaxation to workaround PR9807, which
-// is useful when running bitwise comparison experiments on Darwin. We should be
-// able to remove this once PR9807 is resolved.
-static cl::opt
-MCDisableArithRelaxation("mc-x86-disable-arith-relaxation",
- cl::desc("Disable relaxation of arithmetic instruction for X86"));
-
-static unsigned getFixupKindLog2Size(unsigned Kind) {
- switch (Kind) {
- default: assert(0 && "invalid fixup kind!");
- case FK_PCRel_1:
- case FK_Data_1: return 0;
- case FK_PCRel_2:
- case FK_Data_2: return 1;
- case FK_PCRel_4:
- case X86::reloc_riprel_4byte:
- case X86::reloc_riprel_4byte_movq_load:
- case X86::reloc_signed_4byte:
- case X86::reloc_global_offset_table:
- case FK_Data_4: return 2;
- case FK_PCRel_8:
- case FK_Data_8: return 3;
- }
-}
-
-namespace {
-
-class X86ELFObjectWriter : public MCELFObjectTargetWriter {
-public:
- X86ELFObjectWriter(bool is64Bit, Triple::OSType OSType, uint16_t EMachine,
- bool HasRelocationAddend)
- : MCELFObjectTargetWriter(is64Bit, OSType, EMachine, HasRelocationAddend) {}
-};
-
-class X86AsmBackend : public TargetAsmBackend {
-public:
- X86AsmBackend(const Target &T)
- : TargetAsmBackend() {}
-
- unsigned getNumFixupKinds() const {
- return X86::NumTargetFixupKinds;
- }
-
- const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
- const static MCFixupKindInfo Infos[X86::NumTargetFixupKinds] = {
- { "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel },
- { "reloc_riprel_4byte_movq_load", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel},
- { "reloc_signed_4byte", 0, 4 * 8, 0},
- { "reloc_global_offset_table", 0, 4 * 8, 0}
- };
-
- if (Kind < FirstTargetFixupKind)
- return TargetAsmBackend::getFixupKindInfo(Kind);
-
- assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
- "Invalid kind!");
- return Infos[Kind - FirstTargetFixupKind];
- }
-
- void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
- uint64_t Value) const {
- unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind());
-
- assert(Fixup.getOffset() + Size <= DataSize &&
- "Invalid fixup offset!");
- for (unsigned i = 0; i != Size; ++i)
- Data[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8));
- }
-
- bool MayNeedRelaxation(const MCInst &Inst) const;
-
- void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
-
- bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
-};
-} // end anonymous namespace
-
-static unsigned getRelaxedOpcodeBranch(unsigned Op) {
- switch (Op) {
- default:
- return Op;
-
- case X86::JAE_1: return X86::JAE_4;
- case X86::JA_1: return X86::JA_4;
- case X86::JBE_1: return X86::JBE_4;
- case X86::JB_1: return X86::JB_4;
- case X86::JE_1: return X86::JE_4;
- case X86::JGE_1: return X86::JGE_4;
- case X86::JG_1: return X86::JG_4;
- case X86::JLE_1: return X86::JLE_4;
- case X86::JL_1: return X86::JL_4;
- case X86::JMP_1: return X86::JMP_4;
- case X86::JNE_1: return X86::JNE_4;
- case X86::JNO_1: return X86::JNO_4;
- case X86::JNP_1: return X86::JNP_4;
- case X86::JNS_1: return X86::JNS_4;
- case X86::JO_1: return X86::JO_4;
- case X86::JP_1: return X86::JP_4;
- case X86::JS_1: return X86::JS_4;
- }
-}
-
-static unsigned getRelaxedOpcodeArith(unsigned Op) {
- switch (Op) {
- default:
- return Op;
-
- // IMUL
- case X86::IMUL16rri8: return X86::IMUL16rri;
- case X86::IMUL16rmi8: return X86::IMUL16rmi;
- case X86::IMUL32rri8: return X86::IMUL32rri;
- case X86::IMUL32rmi8: return X86::IMUL32rmi;
- case X86::IMUL64rri8: return X86::IMUL64rri32;
- case X86::IMUL64rmi8: return X86::IMUL64rmi32;
-
- // AND
- case X86::AND16ri8: return X86::AND16ri;
- case X86::AND16mi8: return X86::AND16mi;
- case X86::AND32ri8: return X86::AND32ri;
- case X86::AND32mi8: return X86::AND32mi;
- case X86::AND64ri8: return X86::AND64ri32;
- case X86::AND64mi8: return X86::AND64mi32;
-
- // OR
- case X86::OR16ri8: return X86::OR16ri;
- case X86::OR16mi8: return X86::OR16mi;
- case X86::OR32ri8: return X86::OR32ri;
- case X86::OR32mi8: return X86::OR32mi;
- case X86::OR64ri8: return X86::OR64ri32;
- case X86::OR64mi8: return X86::OR64mi32;
-
- // XOR
- case X86::XOR16ri8: return X86::XOR16ri;
- case X86::XOR16mi8: return X86::XOR16mi;
- case X86::XOR32ri8: return X86::XOR32ri;
- case X86::XOR32mi8: return X86::XOR32mi;
- case X86::XOR64ri8: return X86::XOR64ri32;
- case X86::XOR64mi8: return X86::XOR64mi32;
-
- // ADD
- case X86::ADD16ri8: return X86::ADD16ri;
- case X86::ADD16mi8: return X86::ADD16mi;
- case X86::ADD32ri8: return X86::ADD32ri;
- case X86::ADD32mi8: return X86::ADD32mi;
- case X86::ADD64ri8: return X86::ADD64ri32;
- case X86::ADD64mi8: return X86::ADD64mi32;
-
- // SUB
- case X86::SUB16ri8: return X86::SUB16ri;
- case X86::SUB16mi8: return X86::SUB16mi;
- case X86::SUB32ri8: return X86::SUB32ri;
- case X86::SUB32mi8: return X86::SUB32mi;
- case X86::SUB64ri8: return X86::SUB64ri32;
- case X86::SUB64mi8: return X86::SUB64mi32;
-
- // CMP
- case X86::CMP16ri8: return X86::CMP16ri;
- case X86::CMP16mi8: return X86::CMP16mi;
- case X86::CMP32ri8: return X86::CMP32ri;
- case X86::CMP32mi8: return X86::CMP32mi;
- case X86::CMP64ri8: return X86::CMP64ri32;
- case X86::CMP64mi8: return X86::CMP64mi32;
-
- // PUSH
- case X86::PUSHi8: return X86::PUSHi32;
- case X86::PUSHi16: return X86::PUSHi32;
- case X86::PUSH64i8: return X86::PUSH64i32;
- case X86::PUSH64i16: return X86::PUSH64i32;
- }
-}
-
-static unsigned getRelaxedOpcode(unsigned Op) {
- unsigned R = getRelaxedOpcodeArith(Op);
- if (R != Op)
- return R;
- return getRelaxedOpcodeBranch(Op);
-}
-
-bool X86AsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
- // Branches can always be relaxed.
- if (getRelaxedOpcodeBranch(Inst.getOpcode()) != Inst.getOpcode())
- return true;
-
- if (MCDisableArithRelaxation)
- return false;
-
- // Check if this instruction is ever relaxable.
- if (getRelaxedOpcodeArith(Inst.getOpcode()) == Inst.getOpcode())
- return false;
-
-
- // Check if it has an expression and is not RIP relative.
- bool hasExp = false;
- bool hasRIP = false;
- for (unsigned i = 0; i < Inst.getNumOperands(); ++i) {
- const MCOperand &Op = Inst.getOperand(i);
- if (Op.isExpr())
- hasExp = true;
-
- if (Op.isReg() && Op.getReg() == X86::RIP)
- hasRIP = true;
- }
-
- // FIXME: Why exactly do we need the !hasRIP? Is it just a limitation on
- // how we do relaxations?
- return hasExp && !hasRIP;
-}
-
-// FIXME: Can tblgen help at all here to verify there aren't other instructions
-// we can relax?
-void X86AsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
- // The only relaxations X86 does is from a 1byte pcrel to a 4byte pcrel.
- unsigned RelaxedOp = getRelaxedOpcode(Inst.getOpcode());
-
- if (RelaxedOp == Inst.getOpcode()) {
- SmallString<256> Tmp;
- raw_svector_ostream OS(Tmp);
- Inst.dump_pretty(OS);
- OS << "\n";
- report_fatal_error("unexpected instruction to relax: " + OS.str());
- }
-
- Res = Inst;
- Res.setOpcode(RelaxedOp);
-}
-
-/// WriteNopData - Write optimal nops to the output file for the \arg Count
-/// bytes. This returns the number of bytes written. It may return 0 if
-/// the \arg Count is more than the maximum optimal nops.
-bool X86AsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
- static const uint8_t Nops[10][10] = {
- // nop
- {0x90},
- // xchg %ax,%ax
- {0x66, 0x90},
- // nopl (%[re]ax)
- {0x0f, 0x1f, 0x00},
- // nopl 0(%[re]ax)
- {0x0f, 0x1f, 0x40, 0x00},
- // nopl 0(%[re]ax,%[re]ax,1)
- {0x0f, 0x1f, 0x44, 0x00, 0x00},
- // nopw 0(%[re]ax,%[re]ax,1)
- {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00},
- // nopl 0L(%[re]ax)
- {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00},
- // nopl 0L(%[re]ax,%[re]ax,1)
- {0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
- // nopw 0L(%[re]ax,%[re]ax,1)
- {0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
- // nopw %cs:0L(%[re]ax,%[re]ax,1)
- {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00},
- };
-
- // Write an optimal sequence for the first 15 bytes.
- const uint64_t OptimalCount = (Count < 16) ? Count : 15;
- const uint64_t Prefixes = OptimalCount <= 10 ? 0 : OptimalCount - 10;
- for (uint64_t i = 0, e = Prefixes; i != e; i++)
- OW->Write8(0x66);
- const uint64_t Rest = OptimalCount - Prefixes;
- for (uint64_t i = 0, e = Rest; i != e; i++)
- OW->Write8(Nops[Rest - 1][i]);
-
- // Finish with single byte nops.
- for (uint64_t i = OptimalCount, e = Count; i != e; ++i)
- OW->Write8(0x90);
-
- return true;
-}
-
-/* *** */
-
-namespace {
-class ELFX86AsmBackend : public X86AsmBackend {
-public:
- Triple::OSType OSType;
- ELFX86AsmBackend(const Target &T, Triple::OSType _OSType)
- : X86AsmBackend(T), OSType(_OSType) {
- HasReliableSymbolDifference = true;
- }
-
- virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
- const MCSectionELF &ES = static_cast(Section);
- return ES.getFlags() & ELF::SHF_MERGE;
- }
-};
-
-class ELFX86_32AsmBackend : public ELFX86AsmBackend {
-public:
- ELFX86_32AsmBackend(const Target &T, Triple::OSType OSType)
- : ELFX86AsmBackend(T, OSType) {}
-
- MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return createELFObjectWriter(createELFObjectTargetWriter(),
- OS, /*IsLittleEndian*/ true);
- }
-
- MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
- return new X86ELFObjectWriter(false, OSType, ELF::EM_386, false);
- }
-};
-
-class ELFX86_64AsmBackend : public ELFX86AsmBackend {
-public:
- ELFX86_64AsmBackend(const Target &T, Triple::OSType OSType)
- : ELFX86AsmBackend(T, OSType) {}
-
- MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return createELFObjectWriter(createELFObjectTargetWriter(),
- OS, /*IsLittleEndian*/ true);
- }
-
- MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
- return new X86ELFObjectWriter(true, OSType, ELF::EM_X86_64, true);
- }
-};
-
-class WindowsX86AsmBackend : public X86AsmBackend {
- bool Is64Bit;
-
-public:
- WindowsX86AsmBackend(const Target &T, bool is64Bit)
- : X86AsmBackend(T)
- , Is64Bit(is64Bit) {
- }
-
- MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return createWinCOFFObjectWriter(OS, Is64Bit);
- }
-};
-
-class DarwinX86AsmBackend : public X86AsmBackend {
-public:
- DarwinX86AsmBackend(const Target &T)
- : X86AsmBackend(T) { }
-};
-
-class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
-public:
- DarwinX86_32AsmBackend(const Target &T)
- : DarwinX86AsmBackend(T) {}
-
- MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return createX86MachObjectWriter(OS, /*Is64Bit=*/false,
- object::mach::CTM_i386,
- object::mach::CSX86_ALL);
- }
-};
-
-class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
-public:
- DarwinX86_64AsmBackend(const Target &T)
- : DarwinX86AsmBackend(T) {
- HasReliableSymbolDifference = true;
- }
-
- MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
- return createX86MachObjectWriter(OS, /*Is64Bit=*/true,
- object::mach::CTM_x86_64,
- object::mach::CSX86_ALL);
- }
-
- virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
- // Temporary labels in the string literals sections require symbols. The
- // issue is that the x86_64 relocation format does not allow symbol +
- // offset, and so the linker does not have enough information to resolve the
- // access to the appropriate atom unless an external relocation is used. For
- // non-cstring sections, we expect the compiler to use a non-temporary label
- // for anything that could have an addend pointing outside the symbol.
- //
- // See .
- const MCSectionMachO &SMO = static_cast