@@ -4773,6 +4773,20 @@ static bool parseMLIR(const char *Argv0, std::vector<std::string> filenames,
47734773 }
47744774 if (FOpenMP)
47754775 Argv.push_back (" -fopenmp" );
4776+ if (TargetTripleOpt != " " ) {
4777+ char *chars = (char *)malloc (TargetTripleOpt.length () + 1 );
4778+ memcpy (chars, TargetTripleOpt.data (), TargetTripleOpt.length ());
4779+ chars[TargetTripleOpt.length ()] = 0 ;
4780+ Argv.push_back (" -target" );
4781+ Argv.push_back (chars);
4782+ }
4783+ if (McpuOpt != " " ) {
4784+ auto a = " -mcpu=" + McpuOpt;
4785+ char *chars = (char *)malloc (a.length () + 1 );
4786+ memcpy (chars, a.data (), a.length ());
4787+ chars[a.length ()] = 0 ;
4788+ Argv.push_back (chars);
4789+ }
47764790 if (Standard != " " ) {
47774791 auto a = " -std=" + Standard;
47784792 char *chars = (char *)malloc (a.length () + 1 );
@@ -4787,6 +4801,13 @@ static bool parseMLIR(const char *Argv0, std::vector<std::string> filenames,
47874801 chars[ResourceDir.length ()] = 0 ;
47884802 Argv.push_back (chars);
47894803 }
4804+ if (SysRoot != " " ) {
4805+ Argv.push_back (" --sysroot" );
4806+ char *chars = (char *)malloc (SysRoot.length () + 1 );
4807+ memcpy (chars, SysRoot.data (), SysRoot.length ());
4808+ chars[SysRoot.length ()] = 0 ;
4809+ Argv.push_back (chars);
4810+ }
47904811 if (Verbose) {
47914812 Argv.push_back (" -v" );
47924813 }
@@ -4904,14 +4925,19 @@ static bool parseMLIR(const char *Argv0, std::vector<std::string> filenames,
49044925 Clang->getTarget ().adjustTargetOptions (Clang->getCodeGenOpts (),
49054926 Clang->getTargetOpts ());
49064927
4907- module .get ()->setAttr (
4908- LLVM::LLVMDialect::getDataLayoutAttrName (),
4909- StringAttr::get (module ->getContext (),
4910- Clang->getTarget ().getDataLayoutString ()));
4911- module .get ()->setAttr (
4912- LLVM::LLVMDialect::getTargetTripleAttrName (),
4913- StringAttr::get (module ->getContext (),
4914- Clang->getTarget ().getTriple ().getTriple ()));
4928+ llvm::Triple jobTriple = Clang->getTarget ().getTriple ();
4929+ if (triple.str () == " " || !jobTriple.isNVPTX ()) {
4930+ triple = jobTriple;
4931+ module .get ()->setAttr (
4932+ LLVM::LLVMDialect::getTargetTripleAttrName (),
4933+ StringAttr::get (module ->getContext (),
4934+ Clang->getTarget ().getTriple ().getTriple ()));
4935+ DL = llvm::DataLayout (Clang->getTarget ().getDataLayoutString ());
4936+ module .get ()->setAttr (
4937+ LLVM::LLVMDialect::getDataLayoutAttrName (),
4938+ StringAttr::get (module ->getContext (),
4939+ Clang->getTarget ().getDataLayoutString ()));
4940+ }
49154941
49164942 for (const auto &FIF : Clang->getFrontendOpts ().Inputs ) {
49174943 // Reset the ID tables if we are reusing the SourceManager and parsing
@@ -4930,8 +4956,6 @@ static bool parseMLIR(const char *Argv0, std::vector<std::string> filenames,
49304956 Act.EndSourceFile ();
49314957 }
49324958 }
4933- DL = llvm::DataLayout (Clang->getTarget ().getDataLayoutString ());
4934- triple = Clang->getTarget ().getTriple ();
49354959 }
49364960 return true ;
49374961}
0 commit comments