mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Reduce indentation by early exiting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161356 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ebd78710eb
commit
eda3fc6734
@ -211,41 +211,41 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LTOCodeGenerator::determineTarget(std::string& errMsg) {
|
bool LTOCodeGenerator::determineTarget(std::string& errMsg) {
|
||||||
if ( _target == NULL ) {
|
if ( _target != NULL ) return false;
|
||||||
std::string Triple = _linker.getModule()->getTargetTriple();
|
|
||||||
if (Triple.empty())
|
|
||||||
Triple = sys::getDefaultTargetTriple();
|
|
||||||
|
|
||||||
// create target machine from info for merged modules
|
std::string Triple = _linker.getModule()->getTargetTriple();
|
||||||
const Target *march = TargetRegistry::lookupTarget(Triple, errMsg);
|
if (Triple.empty())
|
||||||
if ( march == NULL )
|
Triple = sys::getDefaultTargetTriple();
|
||||||
return true;
|
|
||||||
|
|
||||||
// The relocation model is actually a static member of TargetMachine and
|
// create target machine from info for merged modules
|
||||||
// needs to be set before the TargetMachine is instantiated.
|
const Target *march = TargetRegistry::lookupTarget(Triple, errMsg);
|
||||||
Reloc::Model RelocModel = Reloc::Default;
|
if ( march == NULL )
|
||||||
switch( _codeModel ) {
|
return true;
|
||||||
case LTO_CODEGEN_PIC_MODEL_STATIC:
|
|
||||||
RelocModel = Reloc::Static;
|
|
||||||
break;
|
|
||||||
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
|
|
||||||
RelocModel = Reloc::PIC_;
|
|
||||||
break;
|
|
||||||
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
|
||||||
RelocModel = Reloc::DynamicNoPIC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// construct LTOModule, hand over ownership of module and target
|
// The relocation model is actually a static member of TargetMachine and
|
||||||
SubtargetFeatures Features;
|
// needs to be set before the TargetMachine is instantiated.
|
||||||
Features.getDefaultSubtargetFeatures(llvm::Triple(Triple));
|
Reloc::Model RelocModel = Reloc::Default;
|
||||||
std::string FeatureStr = Features.getString();
|
switch( _codeModel ) {
|
||||||
TargetOptions Options;
|
case LTO_CODEGEN_PIC_MODEL_STATIC:
|
||||||
LTOModule::getTargetOptions(Options);
|
RelocModel = Reloc::Static;
|
||||||
_target = march->createTargetMachine(Triple, _mCpu, FeatureStr, Options,
|
break;
|
||||||
RelocModel, CodeModel::Default,
|
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
|
||||||
CodeGenOpt::Aggressive);
|
RelocModel = Reloc::PIC_;
|
||||||
|
break;
|
||||||
|
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
||||||
|
RelocModel = Reloc::DynamicNoPIC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// construct LTOModule, hand over ownership of module and target
|
||||||
|
SubtargetFeatures Features;
|
||||||
|
Features.getDefaultSubtargetFeatures(llvm::Triple(Triple));
|
||||||
|
std::string FeatureStr = Features.getString();
|
||||||
|
TargetOptions Options;
|
||||||
|
LTOModule::getTargetOptions(Options);
|
||||||
|
_target = march->createTargetMachine(Triple, _mCpu, FeatureStr, Options,
|
||||||
|
RelocModel, CodeModel::Default,
|
||||||
|
CodeGenOpt::Aggressive);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,6 +409,9 @@ void LTOModule::addDefinedDataSymbol(GlobalValue *v) {
|
|||||||
// Add to list of defined symbols.
|
// Add to list of defined symbols.
|
||||||
addDefinedSymbol(v, false);
|
addDefinedSymbol(v, false);
|
||||||
|
|
||||||
|
if (!v->hasSection() /* || !isTargetDarwin */)
|
||||||
|
return;
|
||||||
|
|
||||||
// Special case i386/ppc ObjC data structures in magic sections:
|
// Special case i386/ppc ObjC data structures in magic sections:
|
||||||
// The issue is that the old ObjC object format did some strange
|
// The issue is that the old ObjC object format did some strange
|
||||||
// contortions to avoid real linker symbols. For instance, the
|
// contortions to avoid real linker symbols. For instance, the
|
||||||
@ -428,26 +431,25 @@ void LTOModule::addDefinedDataSymbol(GlobalValue *v) {
|
|||||||
// a class was missing.
|
// a class was missing.
|
||||||
// The following synthesizes the implicit .objc_* symbols for the linker
|
// The following synthesizes the implicit .objc_* symbols for the linker
|
||||||
// from the ObjC data structures generated by the front end.
|
// from the ObjC data structures generated by the front end.
|
||||||
if (v->hasSection() /* && isTargetDarwin */) {
|
|
||||||
// special case if this data blob is an ObjC class definition
|
|
||||||
if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) {
|
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
|
||||||
addObjCClass(gv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// special case if this data blob is an ObjC category definition
|
// special case if this data blob is an ObjC class definition
|
||||||
else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) {
|
if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) {
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
addObjCCategory(gv);
|
addObjCClass(gv);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// special case if this data blob is the list of referenced classes
|
// special case if this data blob is an ObjC category definition
|
||||||
else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) {
|
else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) {
|
||||||
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
addObjCClassRef(gv);
|
addObjCCategory(gv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// special case if this data blob is the list of referenced classes
|
||||||
|
else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) {
|
||||||
|
if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
|
||||||
|
addObjCClassRef(gv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user