@@ -132,10 +132,6 @@ static cl::opt<ubyte, true> debugInfo(
132132 clEnumValN(3 , " gline-tables-only" , " Add line tables only" )),
133133 cl::location(global.params.symdebug), cl::init(0 ));
134134
135- static cl::opt<unsigned , true >
136- dwarfVersion (" dwarf-version" , cl::desc(" Dwarf version" ), cl::ZeroOrMore,
137- cl::location(global.params.dwarfVersion), cl::Hidden);
138-
139135cl::opt<bool > noAsm (" noasm" , cl::desc(" Disallow use of inline assembler" ),
140136 cl::ZeroOrMore);
141137
@@ -294,21 +290,10 @@ cl::opt<std::string>
294290 " '-deps' alone prints module dependencies "
295291 " (imports/file/version/debug/lib)" ));
296292
297- cl::opt<std::string> mArch (" march" , cl::ZeroOrMore,
298- cl::desc (" Architecture to generate code for:" ));
299-
300293cl::opt<bool > m32bits (" m32" , cl::desc(" 32 bit target" ), cl::ZeroOrMore);
301294
302295cl::opt<bool > m64bits (" m64" , cl::desc(" 64 bit target" ), cl::ZeroOrMore);
303296
304- cl::opt<std::string>
305- mCPU (" mcpu" , cl::ZeroOrMore, cl::value_desc(" cpu-name" ), cl::init(" " ),
306- cl::desc(" Target a specific cpu type (-mcpu=help for details)" ));
307-
308- cl::list<std::string>
309- mAttrs (" mattr" , cl::CommaSeparated, cl::value_desc(" a1,+a2,-a3,..." ),
310- cl::desc(" Target specific attributes (-mattr=help for details)" ));
311-
312297cl::opt<std::string> mTargetTriple (" mtriple" , cl::ZeroOrMore,
313298 cl::desc (" Override target triple" ));
314299
@@ -325,49 +310,7 @@ static cl::list<std::string, StringsAdapter> modFileAliasStrings(
325310 cl::value_desc(" <package.module>=<filespec>" ),
326311 cl::location(modFileAliasStringsStore));
327312
328- cl::opt<llvm::Reloc::Model> mRelocModel (
329- " relocation-model" , cl::desc(" Relocation model" ), cl::ZeroOrMore,
330- #if LDC_LLVM_VER < 309
331- cl::init (llvm::Reloc::Default),
332- #endif
333- clEnumValues (
334- #if LDC_LLVM_VER < 309
335- clEnumValN (llvm::Reloc::Default, " default" ,
336- " Target default relocation model" ),
337- #endif
338- clEnumValN (llvm::Reloc::Static, " static" , " Non-relocatable code" ),
339- clEnumValN(llvm::Reloc::PIC_, " pic" ,
340- " Fully relocatable, position independent code" ),
341- clEnumValN(llvm::Reloc::DynamicNoPIC, " dynamic-no-pic" ,
342- " Relocatable external references, non-relocatable code" )));
343-
344- cl::opt<llvm::CodeModel::Model> mCodeModel (
345- " code-model" , cl::desc(" Code model" ), cl::ZeroOrMore,
346- cl::init(llvm::CodeModel::Default),
347- clEnumValues(
348- clEnumValN (llvm::CodeModel::Default, " default" ,
349- " Target default code model" ),
350- clEnumValN(llvm::CodeModel::Small, " small" , " Small code model" ),
351- clEnumValN(llvm::CodeModel::Kernel, " kernel" , " Kernel code model" ),
352- clEnumValN(llvm::CodeModel::Medium, " medium" , " Medium code model" ),
353- clEnumValN(llvm::CodeModel::Large, " large" , " Large code model" )));
354-
355- cl::opt<FloatABI::Type> mFloatABI (
356- " float-abi" , cl::desc(" ABI/operations to use for floating-point types:" ),
357- cl::ZeroOrMore, cl::init(FloatABI::Default),
358- clEnumValues(
359- clEnumValN (FloatABI::Default, " default" ,
360- " Target default floating-point ABI" ),
361- clEnumValN(FloatABI::Soft, " soft" ,
362- " Software floating-point ABI and operations" ),
363- clEnumValN(FloatABI::SoftFP, " softfp" ,
364- " Soft-float ABI, but hardware floating-point instructions" ),
365- clEnumValN(FloatABI::Hard, " hard" ,
366- " Hardware floating-point ABI and instructions" )));
367-
368- cl::opt<bool >
369- disableFpElim (" disable-fp-elim" , cl::ZeroOrMore,
370- cl::desc (" Disable frame pointer elimination optimization" ));
313+ FloatABI::Type floatABI; // Storage for the dynamically created float-abi option.
371314
372315static cl::opt<bool , true , FlagParser<bool >>
373316 asserts (" asserts" , cl::ZeroOrMore, cl::desc(" (*) Enable assertions" ),
@@ -432,12 +375,10 @@ cl::opt<bool> disableLinkerStripDead(
432375// Math options
433376bool fFastMath ; // Storage for the dynamically created ffast-math option.
434377llvm::FastMathFlags defaultFMF;
435- void setDefaultMathOptions (llvm::TargetMachine &target ) {
378+ void setDefaultMathOptions (llvm::TargetOptions &targetOptions ) {
436379 if (fFastMath ) {
437380 defaultFMF.setUnsafeAlgebra ();
438-
439- llvm::TargetOptions &TO = target.Options ;
440- TO.UnsafeFPMath = true ;
381+ targetOptions.UnsafeFPMath = true ;
441382 }
442383}
443384
@@ -555,13 +496,27 @@ void createClashingOptions() {
555496 // is a clash in the command line options.
556497 renameAndHide (" color" , " llvm-color" );
557498 renameAndHide (" ffast-math" , " llvm-ffast-math" );
499+ renameAndHide (" float-abi" , " llvm-float-abi" );
558500
559501 // Step 2. Add the LDC options.
560502 new cl::opt<bool , true , FlagParser<bool >>(
561503 " color" , cl::ZeroOrMore, cl::location (global.params .color ),
562504 cl::desc (" (*) Force colored console output" ));
563505 new cl::opt<bool , true >(" ffast-math" , cl::ZeroOrMore, cl::location (fFastMath ),
564506 cl::desc (" Set @fastmath for all functions." ));
507+ new cl::opt<FloatABI::Type, true >(
508+ " float-abi" , cl::desc (" ABI/operations to use for floating-point types:" ),
509+ cl::ZeroOrMore, cl::location (floatABI), cl::init (FloatABI::Default),
510+ clEnumValues (
511+ clEnumValN (FloatABI::Default, " default" ,
512+ " Target default floating-point ABI" ),
513+ clEnumValN (FloatABI::Soft, " soft" ,
514+ " Software floating-point ABI and operations" ),
515+ clEnumValN (
516+ FloatABI::SoftFP, " softfp" ,
517+ " Soft-float ABI, but hardware floating-point instructions" ),
518+ clEnumValN (FloatABI::Hard, " hard" ,
519+ " Hardware floating-point ABI and instructions" )));
565520}
566521
567522// / Hides command line options exposed from within LLVM that are unlikely
@@ -595,6 +550,15 @@ void hideLLVMOptions() {
595550 " verify-region-info" , " verify-scev" , " verify-scev-maps" ,
596551 " x86-early-ifcvt" , " x86-use-vzeroupper" , " x86-recip-refinement-steps" ,
597552
553+ " thread-model" , " exception-model" , " enable-fp-mad" ,
554+ " enable-unsafe-fp-math" , " enable-no-infs-fp-math" ,
555+ " enable-no-nans-fp-math" , " enable-no-trapping-fp-math" ,
556+ " denormal-fp-math" , " recip" , " nozero-initialized-in-bss" , " tailcallopt" ,
557+ " stack-symbol-ordering" , " stack-alignment" , " use-ctors" , " emulated-tls" ,
558+ " unique-section-names" , " jump-table-type" , " meabi" , " debugger-tune" ,
559+ " asm-instrumentation" , " mc-relax-all" , " incremental-linker-compatible" ,
560+ " asm-show-inst" ,
561+
598562 // We enable -fdata-sections/-ffunction-sections by default where it makes
599563 // sense for reducing code size, so hide them to avoid confusion.
600564 //
@@ -603,7 +567,19 @@ void hideLLVMOptions() {
603567 // on the target triple (and thus we do not know it until after the
604568 // command
605569 // line has been parsed).
606- " fdata-sections" , " ffunction-sections" };
570+ " fdata-sections" , " ffunction-sections" , " data-sections" ,
571+ " function-sections" };
572+
573+ // pulled in from shared LLVM headers, but unused or not desired in LDC
574+ static const char *const removedOptions[] = {" disable-tail-calls" ,
575+ " fatal-warnings" ,
576+ " filetype" ,
577+ " no-warn" ,
578+ " stackrealign" ,
579+ " start-after" ,
580+ " stop-after" ,
581+ " trap-func" ,
582+ " W" };
607583
608584#if LDC_LLVM_VER >= 307
609585 llvm::StringMap<cl::Option *> &map = cl::getRegisteredOptions ();
@@ -620,6 +596,13 @@ void hideLLVMOptions() {
620596 it->second ->setHiddenFlag (cl::Hidden);
621597 }
622598 }
599+
600+ for (const auto name : removedOptions) {
601+ auto it = map.find (name);
602+ if (it != map.end ()) {
603+ map.erase (it);
604+ }
605+ }
623606}
624607
625608} // namespace opts
0 commit comments