2008-01-06 02:35:39 +01:00
|
|
|
//===- CodeGenTarget.cpp - CodeGen Target Class Wrapper -------------------===//
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2003-10-20 22:20:30 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:37:13 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2003-10-20 22:20:30 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-10-05 21:27:59 +02:00
|
|
|
//
|
2008-01-06 02:35:39 +01:00
|
|
|
// This class wraps target description classes used by the various code
|
2003-10-05 21:27:59 +02:00
|
|
|
// generation TableGen backends. This makes it easier to access the data and
|
|
|
|
// provides a single place that needs to check it for validity. All of these
|
2012-10-25 22:33:17 +02:00
|
|
|
// classes abort on error conditions.
|
2003-10-05 21:27:59 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-08-01 06:04:35 +02:00
|
|
|
#include "CodeGenTarget.h"
|
2006-03-24 20:49:31 +01:00
|
|
|
#include "CodeGenIntrinsics.h"
|
2012-07-07 06:00:00 +02:00
|
|
|
#include "CodeGenSchedule.h"
|
2010-03-27 21:32:26 +01:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2012-12-04 11:37:14 +01:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2004-10-03 21:34:31 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2012-12-04 11:37:14 +01:00
|
|
|
#include "llvm/TableGen/Error.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
2005-10-14 05:54:49 +02:00
|
|
|
#include <algorithm>
|
2004-08-01 05:55:39 +02:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2009-07-29 02:02:19 +02:00
|
|
|
static cl::opt<unsigned>
|
|
|
|
AsmParserNum("asmparsernum", cl::init(0),
|
|
|
|
cl::desc("Make -gen-asm-parser emit assembly parser #N"));
|
|
|
|
|
2004-10-03 21:34:31 +02:00
|
|
|
static cl::opt<unsigned>
|
|
|
|
AsmWriterNum("asmwriternum", cl::init(0),
|
|
|
|
cl::desc("Make -gen-asm-writer emit assembly writer #N"));
|
|
|
|
|
2009-08-11 22:47:22 +02:00
|
|
|
/// getValueType - Return the MVT::SimpleValueType that the specified TableGen
|
2008-06-06 14:08:01 +02:00
|
|
|
/// record corresponds to.
|
2009-08-11 22:47:22 +02:00
|
|
|
MVT::SimpleValueType llvm::getValueType(Record *Rec) {
|
|
|
|
return (MVT::SimpleValueType)Rec->getValueAsInt("Value");
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 20:07:40 +02:00
|
|
|
StringRef llvm::getName(MVT::SimpleValueType T) {
|
2003-10-05 21:27:59 +02:00
|
|
|
switch (T) {
|
2009-08-11 22:47:22 +02:00
|
|
|
case MVT::Other: return "UNKNOWN";
|
|
|
|
case MVT::iPTR: return "TLI.getPointerTy()";
|
|
|
|
case MVT::iPTRAny: return "TLI.getPointerTy()";
|
2009-07-11 00:25:24 +02:00
|
|
|
default: return getEnumName(T);
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-25 20:07:40 +02:00
|
|
|
StringRef llvm::getEnumName(MVT::SimpleValueType T) {
|
2003-10-05 21:27:59 +02:00
|
|
|
switch (T) {
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::Other: return "MVT::Other";
|
|
|
|
case MVT::i1: return "MVT::i1";
|
|
|
|
case MVT::i8: return "MVT::i8";
|
|
|
|
case MVT::i16: return "MVT::i16";
|
|
|
|
case MVT::i32: return "MVT::i32";
|
|
|
|
case MVT::i64: return "MVT::i64";
|
|
|
|
case MVT::i128: return "MVT::i128";
|
2015-01-22 21:14:38 +01:00
|
|
|
case MVT::Any: return "MVT::Any";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::iAny: return "MVT::iAny";
|
|
|
|
case MVT::fAny: return "MVT::fAny";
|
|
|
|
case MVT::vAny: return "MVT::vAny";
|
2011-12-20 01:02:33 +01:00
|
|
|
case MVT::f16: return "MVT::f16";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::f32: return "MVT::f32";
|
|
|
|
case MVT::f64: return "MVT::f64";
|
|
|
|
case MVT::f80: return "MVT::f80";
|
|
|
|
case MVT::f128: return "MVT::f128";
|
2009-08-11 22:47:22 +02:00
|
|
|
case MVT::ppcf128: return "MVT::ppcf128";
|
2010-09-07 22:03:56 +02:00
|
|
|
case MVT::x86mmx: return "MVT::x86mmx";
|
2010-12-21 03:38:05 +01:00
|
|
|
case MVT::Glue: return "MVT::Glue";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::isVoid: return "MVT::isVoid";
|
2012-09-20 00:47:07 +02:00
|
|
|
case MVT::v2i1: return "MVT::v2i1";
|
|
|
|
case MVT::v4i1: return "MVT::v4i1";
|
|
|
|
case MVT::v8i1: return "MVT::v8i1";
|
|
|
|
case MVT::v16i1: return "MVT::v16i1";
|
2012-12-24 11:03:57 +01:00
|
|
|
case MVT::v32i1: return "MVT::v32i1";
|
|
|
|
case MVT::v64i1: return "MVT::v64i1";
|
2015-11-24 16:50:22 +01:00
|
|
|
case MVT::v512i1: return "MVT::v512i1";
|
|
|
|
case MVT::v1024i1: return "MVT::v1024i1";
|
2013-09-24 04:47:27 +02:00
|
|
|
case MVT::v1i8: return "MVT::v1i8";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v2i8: return "MVT::v2i8";
|
|
|
|
case MVT::v4i8: return "MVT::v4i8";
|
|
|
|
case MVT::v8i8: return "MVT::v8i8";
|
|
|
|
case MVT::v16i8: return "MVT::v16i8";
|
|
|
|
case MVT::v32i8: return "MVT::v32i8";
|
2012-12-24 11:03:57 +01:00
|
|
|
case MVT::v64i8: return "MVT::v64i8";
|
2015-11-24 16:50:22 +01:00
|
|
|
case MVT::v128i8: return "MVT::v128i8";
|
|
|
|
case MVT::v256i8: return "MVT::v256i8";
|
2012-09-20 00:47:07 +02:00
|
|
|
case MVT::v1i16: return "MVT::v1i16";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v2i16: return "MVT::v2i16";
|
|
|
|
case MVT::v4i16: return "MVT::v4i16";
|
|
|
|
case MVT::v8i16: return "MVT::v8i16";
|
|
|
|
case MVT::v16i16: return "MVT::v16i16";
|
2012-12-24 11:03:57 +01:00
|
|
|
case MVT::v32i16: return "MVT::v32i16";
|
2015-11-24 16:50:22 +01:00
|
|
|
case MVT::v64i16: return "MVT::v64i16";
|
|
|
|
case MVT::v128i16: return "MVT::v128i16";
|
2012-09-20 00:47:07 +02:00
|
|
|
case MVT::v1i32: return "MVT::v1i32";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v2i32: return "MVT::v2i32";
|
|
|
|
case MVT::v4i32: return "MVT::v4i32";
|
|
|
|
case MVT::v8i32: return "MVT::v8i32";
|
2012-09-20 00:47:07 +02:00
|
|
|
case MVT::v16i32: return "MVT::v16i32";
|
2015-11-24 16:50:22 +01:00
|
|
|
case MVT::v32i32: return "MVT::v32i32";
|
|
|
|
case MVT::v64i32: return "MVT::v64i32";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v1i64: return "MVT::v1i64";
|
|
|
|
case MVT::v2i64: return "MVT::v2i64";
|
|
|
|
case MVT::v4i64: return "MVT::v4i64";
|
|
|
|
case MVT::v8i64: return "MVT::v8i64";
|
2012-09-20 00:47:07 +02:00
|
|
|
case MVT::v16i64: return "MVT::v16i64";
|
2015-11-24 16:50:22 +01:00
|
|
|
case MVT::v32i64: return "MVT::v32i64";
|
2015-04-17 18:11:05 +02:00
|
|
|
case MVT::v1i128: return "MVT::v1i128";
|
2012-01-13 00:14:13 +01:00
|
|
|
case MVT::v2f16: return "MVT::v2f16";
|
2013-10-03 05:29:21 +02:00
|
|
|
case MVT::v4f16: return "MVT::v4f16";
|
2013-08-14 00:34:26 +02:00
|
|
|
case MVT::v8f16: return "MVT::v8f16";
|
2013-09-24 04:47:27 +02:00
|
|
|
case MVT::v1f32: return "MVT::v1f32";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v2f32: return "MVT::v2f32";
|
|
|
|
case MVT::v4f32: return "MVT::v4f32";
|
|
|
|
case MVT::v8f32: return "MVT::v8f32";
|
2012-12-24 11:03:57 +01:00
|
|
|
case MVT::v16f32: return "MVT::v16f32";
|
2013-09-24 04:47:27 +02:00
|
|
|
case MVT::v1f64: return "MVT::v1f64";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::v2f64: return "MVT::v2f64";
|
|
|
|
case MVT::v4f64: return "MVT::v4f64";
|
2012-12-24 11:03:57 +01:00
|
|
|
case MVT::v8f64: return "MVT::v8f64";
|
2015-09-02 15:36:25 +02:00
|
|
|
case MVT::token: return "MVT::token";
|
2009-08-11 22:47:22 +02:00
|
|
|
case MVT::Metadata: return "MVT::Metadata";
|
2010-09-07 20:49:14 +02:00
|
|
|
case MVT::iPTR: return "MVT::iPTR";
|
2009-08-11 22:47:22 +02:00
|
|
|
case MVT::iPTRAny: return "MVT::iPTRAny";
|
2011-11-16 02:02:57 +01:00
|
|
|
case MVT::Untyped: return "MVT::Untyped";
|
2012-02-05 08:21:30 +01:00
|
|
|
default: llvm_unreachable("ILLEGAL VALUE TYPE!");
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-05 23:25:12 +01:00
|
|
|
/// getQualifiedName - Return the name of the specified record, with a
|
|
|
|
/// namespace qualifier if the record contains one.
|
|
|
|
///
|
|
|
|
std::string llvm::getQualifiedName(const Record *R) {
|
2011-05-07 23:22:39 +02:00
|
|
|
std::string Namespace;
|
|
|
|
if (R->getValue("Namespace"))
|
|
|
|
Namespace = R->getValueAsString("Namespace");
|
2008-01-05 23:25:12 +01:00
|
|
|
if (Namespace.empty()) return R->getName();
|
|
|
|
return Namespace + "::" + R->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-05 21:27:59 +02:00
|
|
|
/// getTarget - Return the current instance of the Target class.
|
|
|
|
///
|
2011-06-10 20:40:00 +02:00
|
|
|
CodeGenTarget::CodeGenTarget(RecordKeeper &records)
|
2014-11-28 21:30:37 +01:00
|
|
|
: Records(records) {
|
2003-10-05 21:27:59 +02:00
|
|
|
std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
|
2004-06-04 16:59:42 +02:00
|
|
|
if (Targets.size() == 0)
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("ERROR: No 'Target' subclasses defined!");
|
2003-10-05 21:27:59 +02:00
|
|
|
if (Targets.size() != 1)
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("ERROR: Multiple subclasses of Target defined!");
|
2003-10-05 21:27:59 +02:00
|
|
|
TargetRec = Targets[0];
|
|
|
|
}
|
|
|
|
|
2012-07-07 06:00:00 +02:00
|
|
|
CodeGenTarget::~CodeGenTarget() {
|
|
|
|
}
|
2003-10-05 21:27:59 +02:00
|
|
|
|
|
|
|
const std::string &CodeGenTarget::getName() const {
|
|
|
|
return TargetRec->getName();
|
|
|
|
}
|
|
|
|
|
2008-08-20 23:45:57 +02:00
|
|
|
std::string CodeGenTarget::getInstNamespace() const {
|
2016-01-17 21:38:18 +01:00
|
|
|
for (const CodeGenInstruction *Inst : getInstructionsByEnumValue()) {
|
2010-03-19 02:00:55 +01:00
|
|
|
// Make sure not to pick up "TargetOpcode" by accidentally getting
|
2008-08-20 23:45:57 +02:00
|
|
|
// the namespace off the PHI instruction or something.
|
2014-12-09 09:05:51 +01:00
|
|
|
if (Inst->Namespace != "TargetOpcode")
|
|
|
|
return Inst->Namespace;
|
2008-08-20 23:45:57 +02:00
|
|
|
}
|
|
|
|
|
2010-03-19 02:00:55 +01:00
|
|
|
return "";
|
2008-08-20 23:45:57 +02:00
|
|
|
}
|
|
|
|
|
2003-10-05 21:27:59 +02:00
|
|
|
Record *CodeGenTarget::getInstructionSet() const {
|
|
|
|
return TargetRec->getValueAsDef("InstructionSet");
|
|
|
|
}
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2010-03-19 01:07:20 +01:00
|
|
|
|
2009-07-29 02:02:19 +02:00
|
|
|
/// getAsmParser - Return the AssemblyParser definition for this target.
|
|
|
|
///
|
|
|
|
Record *CodeGenTarget::getAsmParser() const {
|
|
|
|
std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyParsers");
|
|
|
|
if (AsmParserNum >= LI.size())
|
2014-03-29 18:17:15 +01:00
|
|
|
PrintFatalError("Target does not have an AsmParser #" +
|
|
|
|
Twine(AsmParserNum) + "!");
|
2009-07-29 02:02:19 +02:00
|
|
|
return LI[AsmParserNum];
|
|
|
|
}
|
|
|
|
|
2012-01-09 20:13:28 +01:00
|
|
|
/// getAsmParserVariant - Return the AssmblyParserVariant definition for
|
|
|
|
/// this target.
|
|
|
|
///
|
|
|
|
Record *CodeGenTarget::getAsmParserVariant(unsigned i) const {
|
2012-07-07 05:59:51 +02:00
|
|
|
std::vector<Record*> LI =
|
2012-01-09 20:13:28 +01:00
|
|
|
TargetRec->getValueAsListOfDefs("AssemblyParserVariants");
|
|
|
|
if (i >= LI.size())
|
2014-03-29 18:17:15 +01:00
|
|
|
PrintFatalError("Target does not have an AsmParserVariant #" + Twine(i) +
|
|
|
|
"!");
|
2012-01-09 20:13:28 +01:00
|
|
|
return LI[i];
|
|
|
|
}
|
|
|
|
|
2012-07-07 05:59:51 +02:00
|
|
|
/// getAsmParserVariantCount - Return the AssmblyParserVariant definition
|
2012-01-09 20:13:28 +01:00
|
|
|
/// available for this target.
|
|
|
|
///
|
|
|
|
unsigned CodeGenTarget::getAsmParserVariantCount() const {
|
2012-07-07 05:59:51 +02:00
|
|
|
std::vector<Record*> LI =
|
2012-01-09 20:13:28 +01:00
|
|
|
TargetRec->getValueAsListOfDefs("AssemblyParserVariants");
|
|
|
|
return LI.size();
|
|
|
|
}
|
|
|
|
|
2004-08-15 00:50:53 +02:00
|
|
|
/// getAsmWriter - Return the AssemblyWriter definition for this target.
|
|
|
|
///
|
|
|
|
Record *CodeGenTarget::getAsmWriter() const {
|
2005-10-29 00:49:02 +02:00
|
|
|
std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters");
|
|
|
|
if (AsmWriterNum >= LI.size())
|
2014-03-29 18:17:15 +01:00
|
|
|
PrintFatalError("Target does not have an AsmWriter #" +
|
|
|
|
Twine(AsmWriterNum) + "!");
|
2005-10-29 00:49:02 +02:00
|
|
|
return LI[AsmWriterNum];
|
2004-08-15 00:50:53 +02:00
|
|
|
}
|
|
|
|
|
2011-06-10 20:40:00 +02:00
|
|
|
CodeGenRegBank &CodeGenTarget::getRegBank() const {
|
|
|
|
if (!RegBank)
|
2014-11-28 21:30:37 +01:00
|
|
|
RegBank = llvm::make_unique<CodeGenRegBank>(Records);
|
2011-06-10 20:40:00 +02:00
|
|
|
return *RegBank;
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:06:21 +02:00
|
|
|
void CodeGenTarget::ReadRegAltNameIndices() const {
|
|
|
|
RegAltNameIndices = Records.getAllDerivedDefinitions("RegAltNameIndex");
|
2015-11-24 07:24:06 +01:00
|
|
|
std::sort(RegAltNameIndices.begin(), RegAltNameIndices.end(), LessRecord());
|
2011-06-27 23:06:21 +02:00
|
|
|
}
|
|
|
|
|
2010-11-02 19:10:06 +01:00
|
|
|
/// getRegisterByName - If there is a register with the specific AsmName,
|
|
|
|
/// return it.
|
|
|
|
const CodeGenRegister *CodeGenTarget::getRegisterByName(StringRef Name) const {
|
2012-09-12 01:32:17 +02:00
|
|
|
const StringMap<CodeGenRegister*> &Regs = getRegBank().getRegistersByName();
|
|
|
|
StringMap<CodeGenRegister*>::const_iterator I = Regs.find(Name);
|
|
|
|
if (I == Regs.end())
|
2014-04-15 09:20:03 +02:00
|
|
|
return nullptr;
|
2012-09-12 01:32:17 +02:00
|
|
|
return I->second;
|
2010-11-02 19:10:06 +01:00
|
|
|
}
|
|
|
|
|
2010-03-15 07:00:16 +01:00
|
|
|
std::vector<MVT::SimpleValueType> CodeGenTarget::
|
|
|
|
getRegisterVTs(Record *R) const {
|
2011-06-15 06:50:36 +02:00
|
|
|
const CodeGenRegister *Reg = getRegBank().getReg(R);
|
2010-03-15 07:00:16 +01:00
|
|
|
std::vector<MVT::SimpleValueType> Result;
|
2014-12-03 20:58:41 +01:00
|
|
|
for (const auto &RC : getRegBank().getRegClasses()) {
|
2014-12-03 20:58:45 +01:00
|
|
|
if (RC.contains(Reg)) {
|
|
|
|
ArrayRef<MVT::SimpleValueType> InVTs = RC.getValueTypes();
|
2011-06-15 06:50:36 +02:00
|
|
|
Result.insert(Result.end(), InVTs.begin(), InVTs.end());
|
2006-05-16 09:05:30 +02:00
|
|
|
}
|
|
|
|
}
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2010-03-27 21:32:26 +01:00
|
|
|
// Remove duplicates.
|
|
|
|
array_pod_sort(Result.begin(), Result.end());
|
|
|
|
Result.erase(std::unique(Result.begin(), Result.end()), Result.end());
|
2006-05-16 09:05:30 +02:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-08 23:43:21 +02:00
|
|
|
void CodeGenTarget::ReadLegalValueTypes() const {
|
2014-12-03 20:58:45 +01:00
|
|
|
for (const auto &RC : getRegBank().getRegClasses())
|
|
|
|
LegalValueTypes.insert(LegalValueTypes.end(), RC.VTs.begin(), RC.VTs.end());
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2005-10-14 05:54:49 +02:00
|
|
|
// Remove duplicates.
|
2015-11-24 07:22:43 +01:00
|
|
|
array_pod_sort(LegalValueTypes.begin(), LegalValueTypes.end());
|
2005-10-14 05:54:49 +02:00
|
|
|
LegalValueTypes.erase(std::unique(LegalValueTypes.begin(),
|
|
|
|
LegalValueTypes.end()),
|
|
|
|
LegalValueTypes.end());
|
2005-09-08 23:43:21 +02:00
|
|
|
}
|
2004-08-21 06:05:00 +02:00
|
|
|
|
2012-07-07 06:00:00 +02:00
|
|
|
CodeGenSchedModels &CodeGenTarget::getSchedModels() const {
|
|
|
|
if (!SchedModels)
|
2014-11-28 21:30:37 +01:00
|
|
|
SchedModels = llvm::make_unique<CodeGenSchedModels>(Records, *this);
|
2012-07-07 06:00:00 +02:00
|
|
|
return *SchedModels;
|
|
|
|
}
|
2004-08-15 00:50:53 +02:00
|
|
|
|
2004-08-01 07:04:00 +02:00
|
|
|
void CodeGenTarget::ReadInstructions() const {
|
|
|
|
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
|
2006-01-27 02:45:06 +01:00
|
|
|
if (Insts.size() <= 2)
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("No 'Instruction' subclasses defined!");
|
2004-08-01 07:04:00 +02:00
|
|
|
|
2006-01-27 02:45:06 +01:00
|
|
|
// Parse the instructions defined in the .td file.
|
2010-11-01 03:15:23 +01:00
|
|
|
for (unsigned i = 0, e = Insts.size(); i != e; ++i)
|
2014-12-10 07:18:57 +01:00
|
|
|
Instructions[Insts[i]] = llvm::make_unique<CodeGenInstruction>(Insts[i]);
|
2004-08-01 07:04:00 +02:00
|
|
|
}
|
|
|
|
|
2010-03-19 01:23:20 +01:00
|
|
|
static const CodeGenInstruction *
|
|
|
|
GetInstByName(const char *Name,
|
2014-12-10 07:18:57 +01:00
|
|
|
const DenseMap<const Record*,
|
|
|
|
std::unique_ptr<CodeGenInstruction>> &Insts,
|
2010-12-13 01:23:57 +01:00
|
|
|
RecordKeeper &Records) {
|
2010-03-19 02:07:44 +01:00
|
|
|
const Record *Rec = Records.getDef(Name);
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2014-12-10 07:18:57 +01:00
|
|
|
const auto I = Insts.find(Rec);
|
2014-04-15 09:20:03 +02:00
|
|
|
if (!Rec || I == Insts.end())
|
2014-03-29 18:17:15 +01:00
|
|
|
PrintFatalError(Twine("Could not find '") + Name + "' instruction!");
|
2014-12-10 07:18:57 +01:00
|
|
|
return I->second.get();
|
2010-03-19 02:07:44 +01:00
|
|
|
}
|
|
|
|
|
2014-02-05 08:21:07 +01:00
|
|
|
/// \brief Return all of the instructions defined by the target, ordered by
|
|
|
|
/// their enum value.
|
2010-03-19 02:00:55 +01:00
|
|
|
void CodeGenTarget::ComputeInstrsByEnum() const {
|
2013-07-15 10:02:13 +02:00
|
|
|
static const char *const FixedInstrs[] = {
|
2016-07-21 00:58:01 +02:00
|
|
|
#define HANDLE_TARGET_OPCODE(OPC) #OPC,
|
2016-02-04 00:17:32 +01:00
|
|
|
#include "llvm/Target/TargetOpcodes.def"
|
2014-07-25 21:31:34 +02:00
|
|
|
nullptr};
|
2014-12-10 07:18:57 +01:00
|
|
|
const auto &Insts = getInstructions();
|
2010-07-02 23:44:22 +02:00
|
|
|
for (const char *const *p = FixedInstrs; *p; ++p) {
|
2010-12-13 01:23:57 +01:00
|
|
|
const CodeGenInstruction *Instr = GetInstByName(*p, Insts, Records);
|
2010-07-02 23:44:22 +02:00
|
|
|
assert(Instr && "Missing target independent instruction");
|
|
|
|
assert(Instr->Namespace == "TargetOpcode" && "Bad namespace");
|
|
|
|
InstrsByEnum.push_back(Instr);
|
|
|
|
}
|
2010-03-19 02:07:44 +01:00
|
|
|
unsigned EndOfPredefines = InstrsByEnum.size();
|
2010-07-02 23:44:22 +02:00
|
|
|
|
2014-12-09 09:05:51 +01:00
|
|
|
for (const auto &I : Insts) {
|
2014-12-10 07:18:57 +01:00
|
|
|
const CodeGenInstruction *CGI = I.second.get();
|
2010-07-02 23:44:22 +02:00
|
|
|
if (CGI->Namespace != "TargetOpcode")
|
2010-03-19 02:00:55 +01:00
|
|
|
InstrsByEnum.push_back(CGI);
|
|
|
|
}
|
2010-07-02 23:44:22 +02:00
|
|
|
|
|
|
|
assert(InstrsByEnum.size() == Insts.size() && "Missing predefined instr");
|
|
|
|
|
2010-03-19 02:07:44 +01:00
|
|
|
// All of the instructions are now in random order based on the map iteration.
|
|
|
|
// Sort them by name.
|
2014-03-01 12:47:00 +01:00
|
|
|
std::sort(InstrsByEnum.begin() + EndOfPredefines, InstrsByEnum.end(),
|
|
|
|
[](const CodeGenInstruction *Rec1, const CodeGenInstruction *Rec2) {
|
|
|
|
return Rec1->TheDef->getName() < Rec2->TheDef->getName();
|
|
|
|
});
|
2005-01-22 19:58:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-14 07:50:43 +02:00
|
|
|
/// isLittleEndianEncoding - Return whether this target encodes its instruction
|
|
|
|
/// in little-endian format, i.e. bits laid out in the order [0..n]
|
|
|
|
///
|
|
|
|
bool CodeGenTarget::isLittleEndianEncoding() const {
|
|
|
|
return getInstructionSet()->getValueAsBit("isLittleEndianEncoding");
|
|
|
|
}
|
|
|
|
|
2013-12-17 23:37:50 +01:00
|
|
|
/// reverseBitsForLittleEndianEncoding - For little-endian instruction bit
|
|
|
|
/// encodings, reverse the bit order of all instructions.
|
|
|
|
void CodeGenTarget::reverseBitsForLittleEndianEncoding() {
|
|
|
|
if (!isLittleEndianEncoding())
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
|
2014-12-09 09:05:51 +01:00
|
|
|
for (Record *R : Insts) {
|
2013-12-17 23:37:50 +01:00
|
|
|
if (R->getValueAsString("Namespace") == "TargetOpcode" ||
|
|
|
|
R->getValueAsBit("isPseudo"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BitsInit *BI = R->getValueAsBitsInit("Inst");
|
|
|
|
|
|
|
|
unsigned numBits = BI->getNumBits();
|
2016-04-12 08:02:11 +02:00
|
|
|
|
2013-12-17 23:37:50 +01:00
|
|
|
SmallVector<Init *, 16> NewBits(numBits);
|
2016-04-12 08:02:11 +02:00
|
|
|
|
2013-12-17 23:37:50 +01:00
|
|
|
for (unsigned bit = 0, end = numBits / 2; bit != end; ++bit) {
|
|
|
|
unsigned bitSwapIdx = numBits - bit - 1;
|
|
|
|
Init *OrigBit = BI->getBit(bit);
|
|
|
|
Init *BitSwap = BI->getBit(bitSwapIdx);
|
|
|
|
NewBits[bit] = BitSwap;
|
|
|
|
NewBits[bitSwapIdx] = OrigBit;
|
|
|
|
}
|
|
|
|
if (numBits % 2) {
|
|
|
|
unsigned middle = (numBits + 1) / 2;
|
|
|
|
NewBits[middle] = BI->getBit(middle);
|
|
|
|
}
|
|
|
|
|
|
|
|
BitsInit *NewBI = BitsInit::get(NewBits);
|
|
|
|
|
|
|
|
// Update the bits in reversed order so that emitInstrOpBits will get the
|
|
|
|
// correct endianness.
|
|
|
|
R->getValue("Inst")->setValue(NewBI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 21:34:41 +02:00
|
|
|
/// guessInstructionProperties - Return true if it's OK to guess instruction
|
|
|
|
/// properties instead of raising an error.
|
|
|
|
///
|
|
|
|
/// This is configurable as a temporary migration aid. It will eventually be
|
|
|
|
/// permanently false.
|
|
|
|
bool CodeGenTarget::guessInstructionProperties() const {
|
|
|
|
return getInstructionSet()->getValueAsBit("guessInstructionProperties");
|
|
|
|
}
|
|
|
|
|
2005-12-08 03:00:36 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ComplexPattern implementation
|
|
|
|
//
|
|
|
|
ComplexPattern::ComplexPattern(Record *R) {
|
2005-12-08 03:14:08 +01:00
|
|
|
Ty = ::getValueType(R->getValueAsDef("Ty"));
|
|
|
|
NumOperands = R->getValueAsInt("NumOperands");
|
|
|
|
SelectFunc = R->getValueAsString("SelectFunc");
|
|
|
|
RootNodes = R->getValueAsListOfDefs("RootNodes");
|
2006-10-11 23:02:01 +02:00
|
|
|
|
|
|
|
// Parse the properties.
|
|
|
|
Properties = 0;
|
|
|
|
std::vector<Record*> PropList = R->getValueAsListOfDefs("Properties");
|
|
|
|
for (unsigned i = 0, e = PropList.size(); i != e; ++i)
|
|
|
|
if (PropList[i]->getName() == "SDNPHasChain") {
|
|
|
|
Properties |= 1 << SDNPHasChain;
|
2010-12-23 19:28:41 +01:00
|
|
|
} else if (PropList[i]->getName() == "SDNPOptInGlue") {
|
|
|
|
Properties |= 1 << SDNPOptInGlue;
|
2008-01-10 08:59:24 +01:00
|
|
|
} else if (PropList[i]->getName() == "SDNPMayStore") {
|
|
|
|
Properties |= 1 << SDNPMayStore;
|
|
|
|
} else if (PropList[i]->getName() == "SDNPMayLoad") {
|
|
|
|
Properties |= 1 << SDNPMayLoad;
|
|
|
|
} else if (PropList[i]->getName() == "SDNPSideEffect") {
|
|
|
|
Properties |= 1 << SDNPSideEffect;
|
2008-06-25 10:15:39 +02:00
|
|
|
} else if (PropList[i]->getName() == "SDNPMemOperand") {
|
|
|
|
Properties |= 1 << SDNPMemOperand;
|
2010-03-19 06:07:09 +01:00
|
|
|
} else if (PropList[i]->getName() == "SDNPVariadic") {
|
|
|
|
Properties |= 1 << SDNPVariadic;
|
2010-09-21 22:31:19 +02:00
|
|
|
} else if (PropList[i]->getName() == "SDNPWantRoot") {
|
|
|
|
Properties |= 1 << SDNPWantRoot;
|
|
|
|
} else if (PropList[i]->getName() == "SDNPWantParent") {
|
|
|
|
Properties |= 1 << SDNPWantParent;
|
2006-10-11 23:02:01 +02:00
|
|
|
} else {
|
2015-05-12 00:17:13 +02:00
|
|
|
PrintFatalError("Unsupported SD Node property '" +
|
|
|
|
PropList[i]->getName() + "' on ComplexPattern '" +
|
|
|
|
R->getName() + "'!");
|
2006-10-11 23:02:01 +02:00
|
|
|
}
|
2005-12-08 03:00:36 +01:00
|
|
|
}
|
2005-12-08 03:14:08 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// CodeGenIntrinsic Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-07-15 18:31:37 +02:00
|
|
|
CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC,
|
|
|
|
bool TargetOnly) {
|
2016-07-14 20:08:33 +02:00
|
|
|
std::vector<Record*> Defs = RC.getAllDerivedDefinitions("Intrinsic");
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2016-07-15 18:31:37 +02:00
|
|
|
Intrinsics.reserve(Defs.size());
|
2006-03-28 02:15:00 +02:00
|
|
|
|
2016-07-14 20:08:33 +02:00
|
|
|
for (unsigned I = 0, e = Defs.size(); I != e; ++I) {
|
|
|
|
bool isTarget = Defs[I]->getValueAsBit("isTarget");
|
2009-02-05 02:49:45 +01:00
|
|
|
if (isTarget == TargetOnly)
|
2016-07-15 18:31:37 +02:00
|
|
|
Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
|
2009-02-05 02:49:45 +01:00
|
|
|
}
|
2016-07-15 18:31:37 +02:00
|
|
|
std::sort(Intrinsics.begin(), Intrinsics.end(),
|
|
|
|
[](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) {
|
|
|
|
return std::tie(LHS.TargetPrefix, LHS.Name) <
|
|
|
|
std::tie(RHS.TargetPrefix, RHS.Name);
|
2016-01-26 01:55:00 +01:00
|
|
|
});
|
2016-07-15 18:31:37 +02:00
|
|
|
Targets.push_back({"", 0, 0});
|
|
|
|
for (size_t I = 0, E = Intrinsics.size(); I < E; ++I)
|
|
|
|
if (Intrinsics[I].TargetPrefix != Targets.back().Name) {
|
|
|
|
Targets.back().Count = I - Targets.back().Offset;
|
|
|
|
Targets.push_back({Intrinsics[I].TargetPrefix, I, 0});
|
|
|
|
}
|
|
|
|
Targets.back().Count = Intrinsics.size() - Targets.back().Offset;
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|
|
|
|
|
2008-04-03 02:02:49 +02:00
|
|
|
CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
|
2006-03-24 21:25:01 +01:00
|
|
|
TheDef = R;
|
2006-03-24 20:49:31 +01:00
|
|
|
std::string DefName = R->getName();
|
2010-08-06 01:36:21 +02:00
|
|
|
ModRef = ReadWriteMem;
|
2007-04-01 09:20:02 +02:00
|
|
|
isOverloaded = false;
|
2008-06-16 22:29:38 +02:00
|
|
|
isCommutative = false;
|
2011-05-28 08:31:34 +02:00
|
|
|
canThrow = false;
|
2012-05-28 01:20:41 +02:00
|
|
|
isNoReturn = false;
|
2014-03-19 00:51:07 +01:00
|
|
|
isNoDuplicate = false;
|
2015-05-27 01:48:40 +02:00
|
|
|
isConvergent = false;
|
2011-03-11 02:27:24 +01:00
|
|
|
|
|
|
|
if (DefName.size() <= 4 ||
|
2008-11-13 10:08:33 +01:00
|
|
|
std::string(DefName.begin(), DefName.begin() + 4) != "int_")
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("Intrinsic '" + DefName + "' does not start with 'int_'!");
|
2008-11-13 10:08:33 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
EnumName = std::string(DefName.begin()+4, DefName.end());
|
2008-11-13 10:08:33 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field.
|
|
|
|
GCCBuiltinName = R->getValueAsString("GCCBuiltinName");
|
2014-07-04 20:42:25 +02:00
|
|
|
if (R->getValue("MSBuiltinName")) // Ignore a missing MSBuiltinName field.
|
|
|
|
MSBuiltinName = R->getValueAsString("MSBuiltinName");
|
2008-11-13 10:08:33 +01:00
|
|
|
|
|
|
|
TargetPrefix = R->getValueAsString("TargetPrefix");
|
2006-03-24 20:49:31 +01:00
|
|
|
Name = R->getValueAsString("LLVMName");
|
2008-11-13 10:08:33 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
if (Name == "") {
|
|
|
|
// If an explicit name isn't specified, derive one from the DefName.
|
|
|
|
Name = "llvm.";
|
2008-11-13 10:08:33 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
for (unsigned i = 0, e = EnumName.size(); i != e; ++i)
|
2008-11-13 10:08:33 +01:00
|
|
|
Name += (EnumName[i] == '_') ? '.' : EnumName[i];
|
2006-03-24 20:49:31 +01:00
|
|
|
} else {
|
|
|
|
// Verify it starts with "llvm.".
|
2011-03-11 02:27:24 +01:00
|
|
|
if (Name.size() <= 5 ||
|
2008-11-13 10:08:33 +01:00
|
|
|
std::string(Name.begin(), Name.begin() + 5) != "llvm.")
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("Intrinsic '" + DefName + "'s name does not start with 'llvm.'!");
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
// If TargetPrefix is specified, make sure that Name starts with
|
|
|
|
// "llvm.<targetprefix>.".
|
|
|
|
if (!TargetPrefix.empty()) {
|
|
|
|
if (Name.size() < 6+TargetPrefix.size() ||
|
2008-11-13 10:08:33 +01:00
|
|
|
std::string(Name.begin() + 5, Name.begin() + 6 + TargetPrefix.size())
|
|
|
|
!= (TargetPrefix + "."))
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("Intrinsic '" + DefName + "' does not start with 'llvm." +
|
|
|
|
TargetPrefix + ".'!");
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2008-11-13 10:08:33 +01:00
|
|
|
// Parse the list of return types.
|
2009-08-11 22:47:22 +02:00
|
|
|
std::vector<MVT::SimpleValueType> OverloadedVTs;
|
2011-07-30 00:43:06 +02:00
|
|
|
ListInit *TypeList = R->getValueAsListInit("RetTypes");
|
2015-06-02 06:15:57 +02:00
|
|
|
for (unsigned i = 0, e = TypeList->size(); i != e; ++i) {
|
2007-02-27 23:08:27 +01:00
|
|
|
Record *TyEl = TypeList->getElementAsRecord(i);
|
2006-03-24 20:49:31 +01:00
|
|
|
assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!");
|
2009-08-11 22:47:22 +02:00
|
|
|
MVT::SimpleValueType VT;
|
2009-01-07 01:09:01 +01:00
|
|
|
if (TyEl->isSubClassOf("LLVMMatchType")) {
|
2009-04-16 23:51:05 +02:00
|
|
|
unsigned MatchTy = TyEl->getValueAsInt("Number");
|
|
|
|
assert(MatchTy < OverloadedVTs.size() &&
|
|
|
|
"Invalid matching number!");
|
|
|
|
VT = OverloadedVTs[MatchTy];
|
2009-01-07 01:09:01 +01:00
|
|
|
// It only makes sense to use the extended and truncated vector element
|
|
|
|
// variants with iAny types; otherwise, if the intrinsic is not
|
|
|
|
// overloaded, all the types can be specified directly.
|
2014-03-28 13:31:39 +01:00
|
|
|
assert(((!TyEl->isSubClassOf("LLVMExtendedType") &&
|
|
|
|
!TyEl->isSubClassOf("LLVMTruncatedType")) ||
|
2009-08-11 22:47:22 +02:00
|
|
|
VT == MVT::iAny || VT == MVT::vAny) &&
|
2009-08-11 07:03:38 +02:00
|
|
|
"Expected iAny or vAny type");
|
2009-04-16 23:51:05 +02:00
|
|
|
} else {
|
2009-01-07 01:09:01 +01:00
|
|
|
VT = getValueType(TyEl->getValueAsDef("VT"));
|
2009-04-16 23:51:05 +02:00
|
|
|
}
|
2014-01-24 21:50:47 +01:00
|
|
|
if (MVT(VT).isOverloaded()) {
|
2009-04-16 23:51:05 +02:00
|
|
|
OverloadedVTs.push_back(VT);
|
2010-03-24 00:46:27 +01:00
|
|
|
isOverloaded = true;
|
2009-04-16 23:51:05 +02:00
|
|
|
}
|
2010-03-24 00:46:27 +01:00
|
|
|
|
|
|
|
// Reject invalid types.
|
|
|
|
if (VT == MVT::isVoid)
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("Intrinsic '" + DefName + " has void in result type list!");
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2008-11-13 10:08:33 +01:00
|
|
|
IS.RetVTs.push_back(VT);
|
|
|
|
IS.RetTypeDefs.push_back(TyEl);
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2008-11-13 10:08:33 +01:00
|
|
|
// Parse the list of parameter types.
|
|
|
|
TypeList = R->getValueAsListInit("ParamTypes");
|
2015-06-02 06:15:57 +02:00
|
|
|
for (unsigned i = 0, e = TypeList->size(); i != e; ++i) {
|
2008-11-13 10:08:33 +01:00
|
|
|
Record *TyEl = TypeList->getElementAsRecord(i);
|
|
|
|
assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!");
|
2009-08-11 22:47:22 +02:00
|
|
|
MVT::SimpleValueType VT;
|
2009-01-07 01:09:01 +01:00
|
|
|
if (TyEl->isSubClassOf("LLVMMatchType")) {
|
|
|
|
unsigned MatchTy = TyEl->getValueAsInt("Number");
|
2009-04-16 23:51:05 +02:00
|
|
|
assert(MatchTy < OverloadedVTs.size() &&
|
|
|
|
"Invalid matching number!");
|
|
|
|
VT = OverloadedVTs[MatchTy];
|
2009-01-07 01:09:01 +01:00
|
|
|
// It only makes sense to use the extended and truncated vector element
|
|
|
|
// variants with iAny types; otherwise, if the intrinsic is not
|
|
|
|
// overloaded, all the types can be specified directly.
|
2014-03-28 13:31:39 +01:00
|
|
|
assert(((!TyEl->isSubClassOf("LLVMExtendedType") &&
|
2014-12-04 10:40:44 +01:00
|
|
|
!TyEl->isSubClassOf("LLVMTruncatedType") &&
|
2016-11-03 04:23:55 +01:00
|
|
|
!TyEl->isSubClassOf("LLVMVectorSameWidth")) ||
|
2009-08-11 22:47:22 +02:00
|
|
|
VT == MVT::iAny || VT == MVT::vAny) &&
|
2009-08-11 07:03:38 +02:00
|
|
|
"Expected iAny or vAny type");
|
2009-01-07 01:09:01 +01:00
|
|
|
} else
|
|
|
|
VT = getValueType(TyEl->getValueAsDef("VT"));
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2014-01-24 21:50:47 +01:00
|
|
|
if (MVT(VT).isOverloaded()) {
|
2009-04-16 23:51:05 +02:00
|
|
|
OverloadedVTs.push_back(VT);
|
2010-03-24 00:46:27 +01:00
|
|
|
isOverloaded = true;
|
2009-04-16 23:51:05 +02:00
|
|
|
}
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2010-03-24 00:46:27 +01:00
|
|
|
// Reject invalid types.
|
|
|
|
if (VT == MVT::isVoid && i != e-1 /*void at end means varargs*/)
|
2012-10-25 22:33:17 +02:00
|
|
|
PrintFatalError("Intrinsic '" + DefName + " has void in result type list!");
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2008-11-13 10:08:33 +01:00
|
|
|
IS.ParamVTs.push_back(VT);
|
|
|
|
IS.ParamTypeDefs.push_back(TyEl);
|
|
|
|
}
|
|
|
|
|
2006-03-24 20:49:31 +01:00
|
|
|
// Parse the intrinsic properties.
|
2016-02-10 19:40:04 +01:00
|
|
|
ListInit *PropList = R->getValueAsListInit("IntrProperties");
|
2015-06-02 06:15:57 +02:00
|
|
|
for (unsigned i = 0, e = PropList->size(); i != e; ++i) {
|
2007-02-27 23:08:27 +01:00
|
|
|
Record *Property = PropList->getElementAsRecord(i);
|
2006-03-24 20:49:31 +01:00
|
|
|
assert(Property->isSubClassOf("IntrinsicProperty") &&
|
|
|
|
"Expected a property!");
|
2011-03-11 02:27:24 +01:00
|
|
|
|
2006-04-11 00:02:59 +02:00
|
|
|
if (Property->getName() == "IntrNoMem")
|
2006-03-24 20:49:31 +01:00
|
|
|
ModRef = NoMem;
|
|
|
|
else if (Property->getName() == "IntrReadMem")
|
2016-04-21 19:48:02 +02:00
|
|
|
ModRef = ModRefBehavior(ModRef & ~MR_Mod);
|
2016-04-19 23:58:33 +02:00
|
|
|
else if (Property->getName() == "IntrWriteMem")
|
2016-04-21 19:48:02 +02:00
|
|
|
ModRef = ModRefBehavior(ModRef & ~MR_Ref);
|
|
|
|
else if (Property->getName() == "IntrArgMemOnly")
|
|
|
|
ModRef = ModRefBehavior(ModRef & ~MR_Anywhere);
|
2008-06-16 22:29:38 +02:00
|
|
|
else if (Property->getName() == "Commutative")
|
|
|
|
isCommutative = true;
|
2011-05-28 08:31:34 +02:00
|
|
|
else if (Property->getName() == "Throws")
|
|
|
|
canThrow = true;
|
2014-03-19 00:51:07 +01:00
|
|
|
else if (Property->getName() == "IntrNoDuplicate")
|
|
|
|
isNoDuplicate = true;
|
2015-05-27 01:48:40 +02:00
|
|
|
else if (Property->getName() == "IntrConvergent")
|
|
|
|
isConvergent = true;
|
2012-05-28 01:20:41 +02:00
|
|
|
else if (Property->getName() == "IntrNoReturn")
|
|
|
|
isNoReturn = true;
|
2009-01-12 02:12:03 +01:00
|
|
|
else if (Property->isSubClassOf("NoCapture")) {
|
|
|
|
unsigned ArgNo = Property->getValueAsInt("ArgNo");
|
|
|
|
ArgumentAttributes.push_back(std::make_pair(ArgNo, NoCapture));
|
2016-07-11 03:28:42 +02:00
|
|
|
} else if (Property->isSubClassOf("Returned")) {
|
|
|
|
unsigned ArgNo = Property->getValueAsInt("ArgNo");
|
|
|
|
ArgumentAttributes.push_back(std::make_pair(ArgNo, Returned));
|
2013-07-06 02:29:58 +02:00
|
|
|
} else if (Property->isSubClassOf("ReadOnly")) {
|
|
|
|
unsigned ArgNo = Property->getValueAsInt("ArgNo");
|
|
|
|
ArgumentAttributes.push_back(std::make_pair(ArgNo, ReadOnly));
|
2016-07-04 10:01:29 +02:00
|
|
|
} else if (Property->isSubClassOf("WriteOnly")) {
|
|
|
|
unsigned ArgNo = Property->getValueAsInt("ArgNo");
|
|
|
|
ArgumentAttributes.push_back(std::make_pair(ArgNo, WriteOnly));
|
2013-07-06 02:29:58 +02:00
|
|
|
} else if (Property->isSubClassOf("ReadNone")) {
|
|
|
|
unsigned ArgNo = Property->getValueAsInt("ArgNo");
|
|
|
|
ArgumentAttributes.push_back(std::make_pair(ArgNo, ReadNone));
|
2009-01-12 02:12:03 +01:00
|
|
|
} else
|
2012-02-05 08:21:30 +01:00
|
|
|
llvm_unreachable("Unknown property!");
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|
2011-05-28 08:31:34 +02:00
|
|
|
|
|
|
|
// Sort the argument attributes for later benefit.
|
|
|
|
std::sort(ArgumentAttributes.begin(), ArgumentAttributes.end());
|
2006-03-24 20:49:31 +01:00
|
|
|
}
|