@@ -64,8 +64,8 @@ enum class LLVMRustPassKind {
64
64
Module,
65
65
};
66
66
67
- static LLVMRustPassKind to_rust (PassKind kind ) {
68
- switch (kind ) {
67
+ static LLVMRustPassKind toRust (PassKind Kind ) {
68
+ switch (Kind ) {
69
69
case PT_Function:
70
70
return LLVMRustPassKind::Function;
71
71
case PT_Module:
@@ -86,17 +86,17 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
86
86
return nullptr ;
87
87
}
88
88
89
- extern " C" LLVMRustPassKind LLVMRustPassKind (LLVMPassRef rust_pass ) {
90
- assert (rust_pass );
91
- Pass *pass = unwrap (rust_pass );
92
- return to_rust (pass ->getPassKind ());
89
+ extern " C" LLVMRustPassKind LLVMRustPassKind (LLVMPassRef RustPass ) {
90
+ assert (RustPass );
91
+ Pass *Pass = unwrap (RustPass );
92
+ return toRust (Pass ->getPassKind ());
93
93
}
94
94
95
- extern " C" void LLVMRustAddPass (LLVMPassManagerRef PM , LLVMPassRef rust_pass ) {
96
- assert (rust_pass );
97
- Pass *pass = unwrap (rust_pass );
98
- PassManagerBase *pm = unwrap (PM );
99
- pm ->add (pass );
95
+ extern " C" void LLVMRustAddPass (LLVMPassManagerRef PMR , LLVMPassRef RustPass ) {
96
+ assert (RustPass );
97
+ Pass *Pass = unwrap (RustPass );
98
+ PassManagerBase *PMB = unwrap (PMR );
99
+ PMB ->add (Pass );
100
100
}
101
101
102
102
#ifdef LLVM_COMPONENT_X86
@@ -160,7 +160,7 @@ GEN_SUBTARGETS
160
160
#undef SUBTARGET
161
161
162
162
extern " C" bool LLVMRustHasFeature (LLVMTargetMachineRef TM,
163
- const char *feature ) {
163
+ const char *Feature ) {
164
164
TargetMachine *Target = unwrap (TM);
165
165
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo ();
166
166
const FeatureBitset &Bits = MCInfo->getFeatureBits ();
@@ -174,7 +174,7 @@ extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
174
174
GEN_SUBTARGETS { return false ; }
175
175
#undef SUBTARGET
176
176
177
- while (strcmp (feature , FeatureEntry->Key ) != 0 )
177
+ while (strcmp (Feature , FeatureEntry->Key ) != 0 )
178
178
FeatureEntry++;
179
179
180
180
return (Bits & FeatureEntry->Value ) == FeatureEntry->Value ;
@@ -190,8 +190,8 @@ enum class LLVMRustCodeModel {
190
190
Large,
191
191
};
192
192
193
- static CodeModel::Model from_rust (LLVMRustCodeModel model ) {
194
- switch (model ) {
193
+ static CodeModel::Model fromRust (LLVMRustCodeModel Model ) {
194
+ switch (Model ) {
195
195
case LLVMRustCodeModel::Default:
196
196
return CodeModel::Default;
197
197
case LLVMRustCodeModel::JITDefault:
@@ -217,8 +217,8 @@ enum class LLVMRustCodeGenOptLevel {
217
217
Aggressive,
218
218
};
219
219
220
- static CodeGenOpt::Level from_rust (LLVMRustCodeGenOptLevel level ) {
221
- switch (level ) {
220
+ static CodeGenOpt::Level fromRust (LLVMRustCodeGenOptLevel Level ) {
221
+ switch (Level ) {
222
222
case LLVMRustCodeGenOptLevel::None:
223
223
return CodeGenOpt::None;
224
224
case LLVMRustCodeGenOptLevel::Less:
@@ -282,9 +282,9 @@ extern "C" void LLVMRustPrintTargetFeatures(LLVMTargetMachineRef) {
282
282
#endif
283
283
284
284
extern " C" LLVMTargetMachineRef LLVMRustCreateTargetMachine (
285
- const char *triple , const char *cpu , const char *feature ,
286
- LLVMRustCodeModel rust_CM , LLVMRelocMode Reloc,
287
- LLVMRustCodeGenOptLevel rust_OptLevel , bool UseSoftFloat,
285
+ const char *TripleStr , const char *CPU , const char *Feature ,
286
+ LLVMRustCodeModel RustCM , LLVMRelocMode Reloc,
287
+ LLVMRustCodeGenOptLevel RustOptLevel , bool UseSoftFloat,
288
288
bool PositionIndependentExecutable, bool FunctionSections,
289
289
bool DataSections) {
290
290
@@ -293,8 +293,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
293
293
#else
294
294
Optional<Reloc::Model> RM;
295
295
#endif
296
- auto CM = from_rust (rust_CM );
297
- auto OptLevel = from_rust (rust_OptLevel );
296
+ auto CM = fromRust (RustCM );
297
+ auto OptLevel = fromRust (RustOptLevel );
298
298
299
299
switch (Reloc) {
300
300
case LLVMRelocStatic:
@@ -314,17 +314,17 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
314
314
}
315
315
316
316
std::string Error;
317
- Triple Trip (Triple::normalize (triple ));
317
+ Triple Trip (Triple::normalize (TripleStr ));
318
318
const llvm::Target *TheTarget =
319
319
TargetRegistry::lookupTarget (Trip.getTriple (), Error);
320
320
if (TheTarget == nullptr ) {
321
321
LLVMRustSetLastError (Error.c_str ());
322
322
return nullptr ;
323
323
}
324
324
325
- StringRef real_cpu = cpu ;
326
- if (real_cpu == " native" ) {
327
- real_cpu = sys::getHostCPUName ();
325
+ StringRef RealCPU = CPU ;
326
+ if (RealCPU == " native" ) {
327
+ RealCPU = sys::getHostCPUName ();
328
328
}
329
329
330
330
TargetOptions Options;
@@ -340,7 +340,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
340
340
Options.FunctionSections = FunctionSections;
341
341
342
342
TargetMachine *TM = TheTarget->createTargetMachine (
343
- Trip.getTriple (), real_cpu, feature , Options, RM, CM, OptLevel);
343
+ Trip.getTriple (), RealCPU, Feature , Options, RM, CM, OptLevel);
344
344
return wrap (TM);
345
345
}
346
346
@@ -360,45 +360,45 @@ extern "C" void LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
360
360
}
361
361
362
362
extern " C" void LLVMRustConfigurePassManagerBuilder (
363
- LLVMPassManagerBuilderRef PMB , LLVMRustCodeGenOptLevel OptLevel,
363
+ LLVMPassManagerBuilderRef PMBR , LLVMRustCodeGenOptLevel OptLevel,
364
364
bool MergeFunctions, bool SLPVectorize, bool LoopVectorize) {
365
365
// Ignore mergefunc for now as enabling it causes crashes.
366
- // unwrap(PMB )->MergeFunctions = MergeFunctions;
367
- unwrap (PMB )->SLPVectorize = SLPVectorize;
368
- unwrap (PMB )->OptLevel = from_rust (OptLevel);
369
- unwrap (PMB )->LoopVectorize = LoopVectorize;
366
+ // unwrap(PMBR )->MergeFunctions = MergeFunctions;
367
+ unwrap (PMBR )->SLPVectorize = SLPVectorize;
368
+ unwrap (PMBR )->OptLevel = fromRust (OptLevel);
369
+ unwrap (PMBR )->LoopVectorize = LoopVectorize;
370
370
}
371
371
372
372
// Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo`
373
373
// field of a PassManagerBuilder, we expose our own method of doing so.
374
- extern " C" void LLVMRustAddBuilderLibraryInfo (LLVMPassManagerBuilderRef PMB ,
374
+ extern " C" void LLVMRustAddBuilderLibraryInfo (LLVMPassManagerBuilderRef PMBR ,
375
375
LLVMModuleRef M,
376
376
bool DisableSimplifyLibCalls) {
377
377
Triple TargetTriple (unwrap (M)->getTargetTriple ());
378
378
TargetLibraryInfoImpl *TLI = new TargetLibraryInfoImpl (TargetTriple);
379
379
if (DisableSimplifyLibCalls)
380
380
TLI->disableAllFunctions ();
381
- unwrap (PMB )->LibraryInfo = TLI;
381
+ unwrap (PMBR )->LibraryInfo = TLI;
382
382
}
383
383
384
384
// Unfortunately, the LLVM C API doesn't provide a way to create the
385
385
// TargetLibraryInfo pass, so we use this method to do so.
386
- extern " C" void LLVMRustAddLibraryInfo (LLVMPassManagerRef PMB , LLVMModuleRef M,
386
+ extern " C" void LLVMRustAddLibraryInfo (LLVMPassManagerRef PMR , LLVMModuleRef M,
387
387
bool DisableSimplifyLibCalls) {
388
388
Triple TargetTriple (unwrap (M)->getTargetTriple ());
389
389
TargetLibraryInfoImpl TLII (TargetTriple);
390
390
if (DisableSimplifyLibCalls)
391
391
TLII.disableAllFunctions ();
392
- unwrap (PMB )->add (new TargetLibraryInfoWrapperPass (TLII));
392
+ unwrap (PMR )->add (new TargetLibraryInfoWrapperPass (TLII));
393
393
}
394
394
395
395
// Unfortunately, the LLVM C API doesn't provide an easy way of iterating over
396
396
// all the functions in a module, so we do that manually here. You'll find
397
397
// similar code in clang's BackendUtil.cpp file.
398
- extern " C" void LLVMRustRunFunctionPassManager (LLVMPassManagerRef PM ,
398
+ extern " C" void LLVMRustRunFunctionPassManager (LLVMPassManagerRef PMR ,
399
399
LLVMModuleRef M) {
400
400
llvm::legacy::FunctionPassManager *P =
401
- unwrap<llvm::legacy::FunctionPassManager>(PM );
401
+ unwrap<llvm::legacy::FunctionPassManager>(PMR );
402
402
P->doInitialization ();
403
403
404
404
// Upgrade all calls to old intrinsics first.
@@ -418,10 +418,10 @@ extern "C" void LLVMRustSetLLVMOptions(int Argc, char **Argv) {
418
418
// check if they've already been initialized. (This could happen if we're
419
419
// being called from rustpkg, for example). If the arguments change, then
420
420
// that's just kinda unfortunate.
421
- static bool initialized = false ;
422
- if (initialized )
421
+ static bool Initialized = false ;
422
+ if (Initialized )
423
423
return ;
424
- initialized = true ;
424
+ Initialized = true ;
425
425
cl::ParseCommandLineOptions (Argc, Argv);
426
426
}
427
427
@@ -431,8 +431,8 @@ enum class LLVMRustFileType {
431
431
ObjectFile,
432
432
};
433
433
434
- static TargetMachine::CodeGenFileType from_rust (LLVMRustFileType type ) {
435
- switch (type ) {
434
+ static TargetMachine::CodeGenFileType fromRust (LLVMRustFileType Type ) {
435
+ switch (Type ) {
436
436
case LLVMRustFileType::AssemblyFile:
437
437
return TargetMachine::CGFT_AssemblyFile;
438
438
case LLVMRustFileType::ObjectFile:
@@ -444,14 +444,14 @@ static TargetMachine::CodeGenFileType from_rust(LLVMRustFileType type) {
444
444
445
445
extern " C" LLVMRustResult
446
446
LLVMRustWriteOutputFile (LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
447
- LLVMModuleRef M, const char *path ,
448
- LLVMRustFileType rust_FileType ) {
447
+ LLVMModuleRef M, const char *Path ,
448
+ LLVMRustFileType RustFileType ) {
449
449
llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
450
- auto FileType = from_rust (rust_FileType );
450
+ auto FileType = fromRust (RustFileType );
451
451
452
452
std::string ErrorInfo;
453
453
std::error_code EC;
454
- raw_fd_ostream OS (path , EC, sys::fs::F_None);
454
+ raw_fd_ostream OS (Path , EC, sys::fs::F_None);
455
455
if (EC)
456
456
ErrorInfo = EC.message ();
457
457
if (ErrorInfo != " " ) {
@@ -470,12 +470,12 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
470
470
}
471
471
472
472
extern " C" void LLVMRustPrintModule (LLVMPassManagerRef PMR, LLVMModuleRef M,
473
- const char *path ) {
473
+ const char *Path ) {
474
474
llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
475
475
std::string ErrorInfo;
476
476
477
477
std::error_code EC;
478
- raw_fd_ostream OS (path , EC, sys::fs::F_None);
478
+ raw_fd_ostream OS (Path , EC, sys::fs::F_None);
479
479
if (EC)
480
480
ErrorInfo = EC.message ();
481
481
@@ -489,10 +489,10 @@ extern "C" void LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
489
489
extern " C" void LLVMRustPrintPasses () {
490
490
LLVMInitializePasses ();
491
491
struct MyListener : PassRegistrationListener {
492
- void passEnumerate (const PassInfo *info ) {
492
+ void passEnumerate (const PassInfo *Info ) {
493
493
#if LLVM_VERSION_GE(4, 0)
494
- StringRef PassArg = info ->getPassArgument ();
495
- StringRef PassName = info ->getPassName ();
494
+ StringRef PassArg = Info ->getPassArgument ();
495
+ StringRef PassName = Info ->getPassName ();
496
496
if (!PassArg.empty ()) {
497
497
// These unsigned->signed casts could theoretically overflow, but
498
498
// realistically never will (and even if, the result is implementation
@@ -501,37 +501,37 @@ extern "C" void LLVMRustPrintPasses() {
501
501
(int )PassName.size (), PassName.data ());
502
502
}
503
503
#else
504
- if (info ->getPassArgument () && *info ->getPassArgument ()) {
505
- printf (" %15s - %s\n " , info ->getPassArgument (), info ->getPassName ());
504
+ if (Info ->getPassArgument () && *Info ->getPassArgument ()) {
505
+ printf (" %15s - %s\n " , Info ->getPassArgument (), Info ->getPassName ());
506
506
}
507
507
#endif
508
508
}
509
- } listener ;
509
+ } Listener ;
510
510
511
511
PassRegistry *PR = PassRegistry::getPassRegistry ();
512
- PR->enumerateWith (&listener );
512
+ PR->enumerateWith (&Listener );
513
513
}
514
514
515
- extern " C" void LLVMRustAddAlwaysInlinePass (LLVMPassManagerBuilderRef PMB ,
515
+ extern " C" void LLVMRustAddAlwaysInlinePass (LLVMPassManagerBuilderRef PMBR ,
516
516
bool AddLifetimes) {
517
517
#if LLVM_VERSION_GE(4, 0)
518
- unwrap (PMB )->Inliner = llvm::createAlwaysInlinerLegacyPass (AddLifetimes);
518
+ unwrap (PMBR )->Inliner = llvm::createAlwaysInlinerLegacyPass (AddLifetimes);
519
519
#else
520
- unwrap (PMB )->Inliner = createAlwaysInlinerPass (AddLifetimes);
520
+ unwrap (PMBR )->Inliner = createAlwaysInlinerPass (AddLifetimes);
521
521
#endif
522
522
}
523
523
524
- extern " C" void LLVMRustRunRestrictionPass (LLVMModuleRef M, char **symbols ,
525
- size_t len ) {
524
+ extern " C" void LLVMRustRunRestrictionPass (LLVMModuleRef M, char **Symbols ,
525
+ size_t Len ) {
526
526
llvm::legacy::PassManager passes;
527
527
528
528
#if LLVM_VERSION_LE(3, 8)
529
- ArrayRef<const char *> ref (symbols, len );
530
- passes.add (llvm::createInternalizePass (ref ));
529
+ ArrayRef<const char *> Ref (Symbols, Len );
530
+ passes.add (llvm::createInternalizePass (Ref ));
531
531
#else
532
532
auto PreserveFunctions = [=](const GlobalValue &GV) {
533
- for (size_t i = 0 ; i < len; i ++) {
534
- if (GV.getName () == symbols[i ]) {
533
+ for (size_t I = 0 ; I < Len; I ++) {
534
+ if (GV.getName () == Symbols[I ]) {
535
535
return true ;
536
536
}
537
537
}
0 commit comments