@@ -86,7 +86,8 @@ INITIALIZE_PASS(NVVMReflect, "nvvm-reflect",
8686// are the last to be added to the VarMap, and therefore will take precedence over initial
8787// values (i.e. __CUDA_FTZ from module medadata and __CUDA_ARCH from SmVersion).
8888static cl::list<std::string>
89- ReflectList(" nvvm-reflect-add" , cl::value_desc(" name=<int>" ), cl::Hidden,
89+ ReflectList(" nvvm-reflect-list" , cl::value_desc(" name=<int>" ), cl::Hidden,
90+ cl::CommaSeparated,
9091 cl::desc(" list of comma-separated key=value pairs" ),
9192 cl::ValueRequired);
9293
@@ -101,28 +102,17 @@ void NVVMReflect::setVarMap(Module &M) {
101102 M.getModuleFlag (" nvvm-reflect-ftz" )))
102103 VarMap[" __CUDA_FTZ" ] = Flag->getSExtValue ();
103104
104- // / The command line can look as follows :
105- // / -nvvm-reflect-add a=1,b=2 -nvvm-reflect-add c=3,d=0 -nvvm-reflect-add e=2
106- // / The strings "a=1,b=2", "c=3,d=0", "e=2" are available in the
107- // / ReflectList vector. First, each of ReflectList[i] is 'split'
108- // / using "," as the delimiter. Then each of this part is split
109- // / using "=" as the delimiter.
110105 for (StringRef Option : ReflectList) {
111106 LLVM_DEBUG (dbgs () << " ReflectOption : " << Option << " \n " );
112- while (!Option.empty ()) {
113- auto Split = Option.split (' ,' );
114- StringRef NameVal = Split.first ;
115- Option = Split.second ;
116-
117- auto NameValPair = NameVal.split (' =' );
118- assert (!NameValPair.first .empty () && !NameValPair.second .empty () &&
119- " name=val expected" );
120-
121- int Val;
122- if (!to_integer (NameValPair.second .trim (), Val, 10 ))
123- report_fatal_error (" integer value expected" );
124- VarMap[NameValPair.first ] = Val;
125- }
107+ auto [Name, Val] = Option.split (' =' );
108+ if (Name.empty ())
109+ report_fatal_error (" Empty name in nvvm-reflect-list option '" + Option + " '" );
110+ if (Val.empty ())
111+ report_fatal_error (" Missing value in nvvm-reflect- option '" + Option + " '" );
112+ int ValInt;
113+ if (!to_integer (Val.trim (), ValInt, 10 ))
114+ report_fatal_error (" integer value expected in nvvm-reflect-list option '" + Option + " '" );
115+ VarMap[Name] = ValInt;
126116 }
127117}
128118
0 commit comments