@@ -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
@@ -173,12 +169,6 @@ static cl::opt<bool, true>
173169                       cl::desc (" Remove generated object files on success"  ),
174170                       cl::location(global.params.cleanupObjectFiles));
175171
176- //  Disabling Red Zone
177- cl::opt<bool , true >
178-     disableRedZone (" disable-red-zone"  , cl::ZeroOrMore,
179-                    cl::desc (" Do not emit code that uses the red zone."  ),
180-                    cl::location(global.params.disableRedZone));
181- 
182172//  DDoc options
183173static  cl::opt<bool , true > doDdoc (" D"  , cl::desc(" Generate documentation"  ),
184174                                  cl::location(global.params.doDocComments),
@@ -294,21 +284,10 @@ cl::opt<std::string>
294284                        " '-deps' alone prints module dependencies " 
295285                        " (imports/file/version/debug/lib)"  ));
296286
297- cl::opt<std::string> mArch (" march"  , cl::ZeroOrMore,
298-                            cl::desc (" Architecture to generate code for:"  ));
299- 
300287cl::opt<bool > m32bits (" m32"  , cl::desc(" 32 bit target"  ), cl::ZeroOrMore);
301288
302289cl::opt<bool > m64bits (" m64"  , cl::desc(" 64 bit target"  ), cl::ZeroOrMore);
303290
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- 
312291cl::opt<std::string> mTargetTriple (" mtriple"  , cl::ZeroOrMore,
313292                                   cl::desc (" Override target triple"  ));
314293
@@ -325,49 +304,7 @@ static cl::list<std::string, StringsAdapter> modFileAliasStrings(
325304    cl::value_desc(" <package.module>=<filespec>"  ),
326305    cl::location(modFileAliasStringsStore));
327306
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"  ));
307+ FloatABI::Type floatABI; //  Storage for the dynamically created float-abi option.
371308
372309static  cl::opt<bool , true , FlagParser<bool >>
373310    asserts (" asserts"  , cl::ZeroOrMore, cl::desc(" (*) Enable assertions"  ),
@@ -432,12 +369,10 @@ cl::opt<bool> disableLinkerStripDead(
432369//  Math options
433370bool  fFastMath ; //  Storage for the dynamically created ffast-math option.
434371llvm::FastMathFlags defaultFMF;
435- void  setDefaultMathOptions (llvm::TargetMachine &target ) {
372+ void  setDefaultMathOptions (llvm::TargetOptions &targetOptions ) {
436373  if  (fFastMath ) {
437374    defaultFMF.setUnsafeAlgebra ();
438- 
439-     llvm::TargetOptions &TO = target.Options ;
440-     TO.UnsafeFPMath  = true ;
375+     targetOptions.UnsafeFPMath  = true ;
441376  }
442377}
443378
@@ -555,13 +490,27 @@ void createClashingOptions() {
555490  //  is a clash in the command line options.
556491  renameAndHide (" color"  , " llvm-color"  );
557492  renameAndHide (" ffast-math"  , " llvm-ffast-math"  );
493+   renameAndHide (" float-abi"  , " llvm-float-abi"  );
558494
559495  //  Step 2. Add the LDC options.
560496  new  cl::opt<bool , true , FlagParser<bool >>(
561497      " color"  , cl::ZeroOrMore, cl::location (global.params .color ),
562498      cl::desc (" (*) Force colored console output"  ));
563499  new  cl::opt<bool , true >(" ffast-math"  , cl::ZeroOrMore, cl::location (fFastMath ),
564500                          cl::desc (" Set @fastmath for all functions."  ));
501+   new  cl::opt<FloatABI::Type, true >(
502+       " float-abi"  , cl::desc (" ABI/operations to use for floating-point types:"  ),
503+       cl::ZeroOrMore, cl::location (floatABI), cl::init (FloatABI::Default),
504+       clEnumValues (
505+           clEnumValN (FloatABI::Default, " default"  ,
506+                      " Target default floating-point ABI"  ),
507+           clEnumValN (FloatABI::Soft, " soft"  ,
508+                      " Software floating-point ABI and operations"  ),
509+           clEnumValN (
510+               FloatABI::SoftFP, " softfp"  ,
511+               " Soft-float ABI, but hardware floating-point instructions"  ),
512+           clEnumValN (FloatABI::Hard, " hard"  ,
513+                      " Hardware floating-point ABI and instructions"  )));
565514}
566515
567516// / Hides command line options exposed from within LLVM that are unlikely
@@ -595,6 +544,16 @@ void hideLLVMOptions() {
595544      " verify-region-info"  , " verify-scev"  , " verify-scev-maps"  ,
596545      " x86-early-ifcvt"  , " x86-use-vzeroupper"  , " x86-recip-refinement-steps"  ,
597546
547+       " thread-model"  , " exception-model"  , " enable-fp-mad"  ,
548+       " enable-unsafe-fp-math"  , " enable-no-infs-fp-math"  ,
549+       " enable-no-nans-fp-math"  , " enable-no-trapping-fp-math"  ,
550+       " denormal-fp-math"  , " soft-float"  , " recip"  , " nozero-initialized-in-bss"  ,
551+       " tailcallopt"  , " stack-symbol-ordering"  , " stack-alignment"  , " enable-pie"  ,
552+       " use-ctors"  , " use-init-array"  , " emulated-tls"  , " unique-section-names"  ,
553+       " jump-table-type"  , " meabi"  , " debugger-tune"  , " asm-instrumentation"  ,
554+       " mc-relax-all"  , " incremental-linker-compatible"  , " asm-show-inst"  , " fcfi"  ,
555+       " cfi-type"  , " cfi-enforcing"  , " cfi-func-name"  , " pie-copy-relocations"  ,
556+ 
598557      //  We enable -fdata-sections/-ffunction-sections by default where it makes
599558      //  sense for reducing code size, so hide them to avoid confusion.
600559      // 
@@ -603,7 +562,20 @@ void hideLLVMOptions() {
603562      //  on the target triple (and thus we do not know it until after the
604563      //  command
605564      //  line has been parsed).
606-       " fdata-sections"  , " ffunction-sections"  };
565+       " fdata-sections"  , " ffunction-sections"  , " data-sections"  ,
566+       " function-sections"  };
567+ 
568+   //  pulled in from shared LLVM headers, but unused or not desired in LDC
569+   static  const  char  *const  removedOptions[] = {" disable-tail-calls"  ,
570+                                                " fatal-warnings"  ,
571+                                                " filetype"  ,
572+                                                " no-deprecated-warn"  ,
573+                                                " no-warn"  ,
574+                                                " stackrealign"  ,
575+                                                " start-after"  ,
576+                                                " stop-after"  ,
577+                                                " trap-func"  ,
578+                                                " W"  };
607579
608580#if  LDC_LLVM_VER >= 307
609581  llvm::StringMap<cl::Option *> &map = cl::getRegisteredOptions ();
@@ -620,6 +592,13 @@ void hideLLVMOptions() {
620592      it->second ->setHiddenFlag (cl::Hidden);
621593    }
622594  }
595+ 
596+   for  (const  auto  name : removedOptions) {
597+     auto  it = map.find (name);
598+     if  (it != map.end ()) {
599+       map.erase (it);
600+     }
601+   }
623602}
624603
625604} //  namespace opts
0 commit comments