Skip to content

Commit

Permalink
[XCore] Fix some Clang-tidy modernize and Include What You Use warnin…
Browse files Browse the repository at this point in the history
…gs; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292988 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EugeneZelenko committed Jan 24, 2017
1 parent e8e3365 commit adb0ce8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 42 deletions.
16 changes: 12 additions & 4 deletions lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
//
//===----------------------------------------------------------------------===//

#include "XCoreMCTargetDesc.h"
#include "InstPrinter/XCoreInstPrinter.h"
#include "XCoreMCAsmInfo.h"
#include "MCTargetDesc/XCoreMCAsmInfo.h"
#include "MCTargetDesc/XCoreMCTargetDesc.h"
#include "XCoreTargetStreamer.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/TargetRegistry.h"

using namespace llvm;
Expand Down Expand Up @@ -79,20 +83,25 @@ static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
}

XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
XCoreTargetStreamer::~XCoreTargetStreamer() {}

XCoreTargetStreamer::~XCoreTargetStreamer() = default;

namespace {

class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
formatted_raw_ostream &OS;

public:
XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);

void emitCCTopData(StringRef Name) override;
void emitCCTopFunction(StringRef Name) override;
void emitCCBottomData(StringRef Name) override;
void emitCCBottomFunction(StringRef Name) override;
};

} // end anonymous namespace

XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS)
: XCoreTargetStreamer(S), OS(OS) {}
Expand All @@ -112,7 +121,6 @@ void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
OS << "\t.cc_bottom " << Name << ".function\n";
}
}

static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS,
Expand Down
8 changes: 4 additions & 4 deletions lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#ifndef LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H
#define LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H

#include "llvm/Support/DataTypes.h"

namespace llvm {

class Target;

Target &getTheXCoreTarget();

} // End llvm namespace
} // end namespace llvm

// Defines symbolic names for XCore registers. This defines a mapping from
// register name to register number.
Expand All @@ -36,4 +36,4 @@ Target &getTheXCoreTarget();
#define GET_SUBTARGETINFO_ENUM
#include "XCoreGenSubtargetInfo.inc"

#endif
#endif // LLVM_LIB_TARGET_XCORE_MCTARGETDESC_XCOREMCTARGETDESC_H
44 changes: 17 additions & 27 deletions lib/Target/XCore/XCoreMachineFunctionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,39 @@
#ifndef LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H
#define LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H

#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include <cassert>
#include <utility>
#include <vector>

namespace llvm {

// Forward declarations
class Function;

/// XCoreFunctionInfo - This class is derived from MachineFunction private
/// XCore target-specific information for each MachineFunction.
class XCoreFunctionInfo : public MachineFunctionInfo {
virtual void anchor();
bool LRSpillSlotSet;
bool LRSpillSlotSet = false;
int LRSpillSlot;
bool FPSpillSlotSet;
bool FPSpillSlotSet = false;
int FPSpillSlot;
bool EHSpillSlotSet;
bool EHSpillSlotSet = false;
int EHSpillSlot[2];
unsigned ReturnStackOffset;
bool ReturnStackOffsetSet;
int VarArgsFrameIndex;
mutable int CachedEStackSize;
bool ReturnStackOffsetSet = false;
int VarArgsFrameIndex = 0;
mutable int CachedEStackSize = -1;
std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>>
SpillLabels;

virtual void anchor();

public:
XCoreFunctionInfo() :
LRSpillSlotSet(false),
FPSpillSlotSet(false),
EHSpillSlotSet(false),
ReturnStackOffsetSet(false),
VarArgsFrameIndex(0),
CachedEStackSize(-1) {}
XCoreFunctionInfo() = default;

explicit XCoreFunctionInfo(MachineFunction &MF) :
LRSpillSlotSet(false),
FPSpillSlotSet(false),
EHSpillSlotSet(false),
ReturnStackOffsetSet(false),
VarArgsFrameIndex(0),
CachedEStackSize(-1) {}
explicit XCoreFunctionInfo(MachineFunction &MF) {}

~XCoreFunctionInfo() {}
~XCoreFunctionInfo() override = default;

void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; }
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
Expand Down Expand Up @@ -101,6 +90,7 @@ class XCoreFunctionInfo : public MachineFunctionInfo {
return SpillLabels;
}
};
} // End llvm namespace

#endif
} // end namespace llvm

#endif // LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H
18 changes: 12 additions & 6 deletions lib/Target/XCore/XCoreTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
//
//===----------------------------------------------------------------------===//

#include "MCTargetDesc/XCoreMCTargetDesc.h"
#include "XCore.h"
#include "XCoreTargetMachine.h"
#include "XCoreTargetObjectFile.h"
#include "XCoreTargetTransformInfo.h"
#include "XCore.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/TargetRegistry.h"

using namespace llvm;

static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
Expand All @@ -38,14 +42,15 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT,
: LLVMTargetMachine(
T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32",
TT, CPU, FS, Options, getEffectiveRelocModel(RM), CM, OL),
TLOF(make_unique<XCoreTargetObjectFile>()),
TLOF(llvm::make_unique<XCoreTargetObjectFile>()),
Subtarget(TT, CPU, FS, *this) {
initAsmInfo();
}

XCoreTargetMachine::~XCoreTargetMachine() {}
XCoreTargetMachine::~XCoreTargetMachine() = default;

namespace {

/// XCore Code Generator Pass Configuration Options.
class XCorePassConfig : public TargetPassConfig {
public:
Expand All @@ -61,7 +66,8 @@ class XCorePassConfig : public TargetPassConfig {
bool addInstSelector() override;
void addPreEmitPass() override;
};
} // namespace

} // end anonymous namespace

TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
return new XCorePassConfig(this, PM);
Expand Down
9 changes: 8 additions & 1 deletion lib/Target/XCore/XCoreTargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
#define LLVM_LIB_TARGET_XCORE_XCORETARGETMACHINE_H

#include "XCoreSubtarget.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Target/TargetMachine.h"
#include <memory>

namespace llvm {

class XCoreTargetMachine : public LLVMTargetMachine {
std::unique_ptr<TargetLoweringObjectFile> TLOF;
XCoreSubtarget Subtarget;

public:
XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
StringRef FS, const TargetOptions &Options,
Expand All @@ -38,11 +44,12 @@ class XCoreTargetMachine : public LLVMTargetMachine {
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;

TargetIRAnalysis getTargetIRAnalysis() override;

TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get();
}
};

} // end namespace llvm

#endif
#endif // LLVM_LIB_TARGET_XCORE_XCORETARGETMACHINE_H

0 comments on commit adb0ce8

Please sign in to comment.