Skip to content

Commit 50f02cb

Browse files
committed
Move global variables in TargetMachine into new TargetOptions class. As an API
change, now you need a TargetOptions object to create a TargetMachine. Clang patch to follow. One small functionality change in PTX. PTX had commented out the machine verifier parts in their copy of printAndVerify. That now calls the version in LLVMTargetMachine. Users of PTX who need verification disabled should rely on not passing the command-line flag to enable it. llvm-svn: 145714
1 parent 7276397 commit 50f02cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+728
-602
lines changed

llvm/include/llvm/CodeGen/Analysis.h

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos,
7070
///
7171
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred);
7272

73+
/// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
74+
/// return the equivalent code if we're allowed to assume that NaNs won't occur.
75+
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC);
76+
7377
/// getICmpCondCode - Return the ISD condition code corresponding to
7478
/// the given LLVM IR integer condition code.
7579
///

llvm/include/llvm/Support/TargetRegistry.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace llvm {
4444
class MCTargetAsmLexer;
4545
class MCTargetAsmParser;
4646
class TargetMachine;
47+
class TargetOptions;
4748
class raw_ostream;
4849
class formatted_raw_ostream;
4950

@@ -86,6 +87,7 @@ namespace llvm {
8687
StringRef TT,
8788
StringRef CPU,
8889
StringRef Features,
90+
const TargetOptions &Options,
8991
Reloc::Model RM,
9092
CodeModel::Model CM,
9193
CodeGenOpt::Level OL);
@@ -334,13 +336,14 @@ namespace llvm {
334336
/// either the target triple from the module, or the target triple of the
335337
/// host if that does not exist.
336338
TargetMachine *createTargetMachine(StringRef Triple, StringRef CPU,
337-
StringRef Features,
339+
StringRef Features, const TargetOptions &Options,
338340
Reloc::Model RM = Reloc::Default,
339341
CodeModel::Model CM = CodeModel::Default,
340342
CodeGenOpt::Level OL = CodeGenOpt::Default) const {
341343
if (!TargetMachineCtorFn)
342344
return 0;
343-
return TargetMachineCtorFn(*this, Triple, CPU, Features, RM, CM, OL);
345+
return TargetMachineCtorFn(*this, Triple, CPU, Features, Options,
346+
RM, CM, OL);
344347
}
345348

346349
/// createMCAsmBackend - Create a target specific assembly parser.
@@ -1017,10 +1020,11 @@ namespace llvm {
10171020
private:
10181021
static TargetMachine *Allocator(const Target &T, StringRef TT,
10191022
StringRef CPU, StringRef FS,
1023+
const TargetOptions &Options,
10201024
Reloc::Model RM,
10211025
CodeModel::Model CM,
10221026
CodeGenOpt::Level OL) {
1023-
return new TargetMachineImpl(T, TT, CPU, FS, RM, CM, OL);
1027+
return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL);
10241028
}
10251029
};
10261030

llvm/include/llvm/Target/Target.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class Predicate<string cond> {
423423
/// NoHonorSignDependentRounding - This predicate is true if support for
424424
/// sign-dependent-rounding is not enabled.
425425
def NoHonorSignDependentRounding
426-
: Predicate<"!HonorSignDependentRoundingFPMath()">;
426+
: Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
427427

428428
class Requires<list<Predicate> preds> {
429429
list<Predicate> Predicates = preds;

llvm/include/llvm/Target/TargetMachine.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_TARGET_TARGETMACHINE_H
1515
#define LLVM_TARGET_TARGETMACHINE_H
1616

17+
#include "llvm/Target/TargetOptions.h"
1718
#include "llvm/MC/MCCodeGenInfo.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include <cassert>
@@ -63,7 +64,7 @@ class TargetMachine {
6364
void operator=(const TargetMachine &); // DO NOT IMPLEMENT
6465
protected: // Can only create subclasses.
6566
TargetMachine(const Target &T, StringRef TargetTriple,
66-
StringRef CPU, StringRef FS);
67+
StringRef CPU, StringRef FS, const TargetOptions &Options);
6768

6869
/// getSubtargetImpl - virtual method implemented by subclasses that returns
6970
/// a reference to that target's TargetSubtargetInfo-derived member variable.
@@ -101,6 +102,8 @@ class TargetMachine {
101102
const StringRef getTargetCPU() const { return TargetCPU; }
102103
const StringRef getTargetFeatureString() const { return TargetFS; }
103104

105+
TargetOptions Options;
106+
104107
// Interfaces to the major aspects of target machine information:
105108
// -- Instruction opcode and operand information
106109
// -- Pipelines and scheduling information
@@ -284,10 +287,20 @@ class TargetMachine {
284287
class LLVMTargetMachine : public TargetMachine {
285288
protected: // Can only create subclasses.
286289
LLVMTargetMachine(const Target &T, StringRef TargetTriple,
287-
StringRef CPU, StringRef FS,
290+
StringRef CPU, StringRef FS, TargetOptions Options,
288291
Reloc::Model RM, CodeModel::Model CM,
289292
CodeGenOpt::Level OL);
290293

294+
/// printNoVerify - Add a pass to dump the machine function, if debugging is
295+
/// enabled.
296+
///
297+
void printNoVerify(PassManagerBase &PM, const char *Banner) const;
298+
299+
/// printAndVerify - Add a pass to dump then verify the machine function, if
300+
/// those steps are enabled.
301+
///
302+
void printAndVerify(PassManagerBase &PM, const char *Banner) const;
303+
291304
private:
292305
/// addCommonCodeGenPasses - Add standard LLVM codegen passes used for
293306
/// both emitting to assembly files or machine code output.

0 commit comments

Comments
 (0)