@@ -124,6 +124,9 @@ static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
124124 if (IK.getLanguage () == InputKind::OpenCL && !Args.hasArg (OPT_cl_opt_disable))
125125 DefaultOpt = llvm::CodeGenOpt::Default;
126126
127+ if (Args.hasArg (OPT_emit_spirv))
128+ return 0 ; // LLVM-SPIRV translator expects not optimized IR
129+
127130 if (Arg *A = Args.getLastArg (options::OPT_O_Group)) {
128131 if (A->getOption ().matches (options::OPT_O0))
129132 return llvm::CodeGenOpt::None;
@@ -1183,6 +1186,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
11831186 }
11841187 }
11851188
1189+ Opts.EmitOpenCLArgMetadata |= Args.hasArg (OPT_emit_spirv);
1190+
11861191 if (Arg *A = Args.getLastArg (OPT_fdenormal_fp_math_EQ)) {
11871192 StringRef Val = A->getValue ();
11881193 if (Val == " ieee" )
@@ -1606,6 +1611,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
16061611 Opts.ProgramAction = frontend::EmitAssembly; break ;
16071612 case OPT_emit_llvm_bc:
16081613 Opts.ProgramAction = frontend::EmitBC; break ;
1614+ case OPT_emit_spirv:
1615+ Opts.ProgramAction = frontend::EmitSPIRV; break ;
16091616 case OPT_emit_html:
16101617 Opts.ProgramAction = frontend::EmitHTML; break ;
16111618 case OPT_emit_llvm:
@@ -3033,6 +3040,7 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
30333040 case frontend::ASTView:
30343041 case frontend::EmitAssembly:
30353042 case frontend::EmitBC:
3043+ case frontend::EmitSPIRV:
30363044 case frontend::EmitHTML:
30373045 case frontend::EmitLLVM:
30383046 case frontend::EmitLLVMOnly:
0 commit comments