[llvm] r205338 - isTargetWindows() renamed to isTargetKnownWindowsMSVC()

Saleem Abdulrasool compnerd at compnerd.org
Sat Apr 5 15:02:28 PDT 2014


On Tue, Apr 1, 2014 at 10:48 PM, Yaron Keren <yaron.keren at gmail.com> wrote:

> Is the UnknownEnvironment actually used to produce code, a real target or
> a default value when the environment was not provided? If the later we
> can make the MSVC environment the default and get rid of
> UnknownEnvironment
>

UnknownEnvironment is used as a marker to indicate that no environment has
been provided.  It should end up getting treated as if MSVC was specified.
 We should default to MSVC on Windows unless otherwise specified IMO, and
simply remove the use of the UnknownEnvironment for output.  It is just a
marker to indicate no environment is specified.


> Triple::MinGW should not exists anymore, yes. It's a bit tricky since
> Triple::normalize first parses the string and then normalizes, so in
> between a MinGW OS does exist.
>

Fortunately, Reid pushed me to do the right thing with my previous change.
 clang no longer directly references llvm::Triple::MinGW.  So, it should
now be possible to clean it up without any consequences.  We should be able
to handle the user providing mingw32 as part of a triple without having an
explicit value for it.  The triple tests should ensure that we dont break
that.


> 2014-04-02 8:34 GMT+03:00 Saleem Abdulrasool <compnerd at compnerd.org>:
>
> On Tue, Apr 1, 2014 at 9:52 PM, Yaron Keren <yaron.keren at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I had added/modified four functions corresponding exactly to the ones in
>>> Triple.h in r205393 to avoid confusion.
>>>
>>> However, this is not completely clear. You are highlighting a very
>>> important issue here.
>>>
>>> You listed the four environments
>>>
>>> * MSVC: The MS ABI, MSVCRT environment as defined by Microsoft
>>> * GNU: The MinGW32/MinGW32-W64 environment which uses MSVCRT and
>>> auxiliary libraries
>>> * Itanium: The MSVCRT environment + libc++ built with Itanium ABI
>>> * Cygnus: The Cygwin environment which uses custom libraries for
>>> everything
>>>
>>> but there is a fifth one, the UnknownEnvironment.
>>>
>>
>> Correct, the fifth element is tricky.  It is the reason that the original
>> set of changes for the Windows target triples introduced
>> isKnownWindowsMSVCEnvironment() and isWindowsMSVCEnvironment().  The
>> difference is that the unknown environment is the default environment and
>> needed to be handled for the cross-over to the canonicalised triples.
>>  i686-pc-win32 maps to an unknown environment (which is supposed to be
>> handled as if it were the MSVC environment).
>>
>>
>>> I have no idea what is the UnknownEnvironment on Windows but it's actually
>>> being used by isWindowsMSVCEnvironment() called in several places in the
>>> code. OTOH, The Itanium environment is actually used just in one
>>> location, InitHeaderSearch.cpp.
>>>
>>
>> The Itanium environment is not fully fleshed out yet (it is meant for use
>> for the Windows on ARM work that is currently ongoing).
>>
>>
>>> The UnknownEnvironment may have been used in the past instead of the
>>> generic Itanium  environment?
>>>
>>
>> No, the Itanium environment is recently introduced into the LLVM
>> repositories.
>>
>>
>>> If so, the usage of Unknown enviroment on WIndows should be replaced
>>> with the Itanium enviroment, and the corresponding functions both in
>>> Triple.h and X86Subtarget.h renamed and modified accordingly?
>>>
>>> What do you think?
>>>
>>
>> If we can find all the locations that the UnknownEnvironment crops up
>> handle it properly, that would certainly be ideal.  If it can be removed at
>> all sites, we would also be able to remove the
>> isKnownWindowsMSVCEnvironment in favour of isWindowsMSVCEnvironment as well.
>>
>> I believe that the dust has somewhat settled from the triple
>> canonicalisation changes, and I hope to actually get around to cleaning up
>> some of the vestiges of the old triple handling for the various Windows
>> environments (e.g. removal of MinGW32 from OS).  I can try to see if it is
>> possible to now sweep up the unknown environment as well.
>>
>>
>>> Yaron
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2014-04-02 4:22 GMT+03:00 Saleem Abdulrasool <compnerd at compnerd.org>:
>>>
>>> On Tue, Apr 1, 2014 at 11:15 AM, Yaron Keren <yaron.keren at gmail.com>wrote:
>>>>
>>>>> Author: yrnkrn
>>>>> Date: Tue Apr  1 13:15:34 2014
>>>>> New Revision: 205338
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=205338&view=rev
>>>>> Log:
>>>>> isTargetWindows() renamed to isTargetKnownWindowsMSVC()
>>>>> to reflect its current functionality.
>>>>>
>>>>
>>>> The OS is still Windows.  If you are going to split up the subtarget
>>>> into the respective environments, then you should have the following at the
>>>> very least:
>>>>
>>>> isTargetWindowsMSVC
>>>> isTargetWindowsGNU
>>>> isTargetWindowsCygnus
>>>> isTargetWindowsItanium
>>>>
>>>>
>>>>> Based on Takumi NAKAMURA suggestion.
>>>>>
>>>>>
>>>>> Modified:
>>>>>     llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
>>>>>     llvm/trunk/lib/Target/X86/X86FastISel.cpp
>>>>>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>>>>>     llvm/trunk/lib/Target/X86/X86ISelLowering.h
>>>>>     llvm/trunk/lib/Target/X86/X86Subtarget.h
>>>>>     llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Tue Apr  1 13:15:34
>>>>> 2014
>>>>> @@ -623,7 +623,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
>>>>>      OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
>>>>>    }
>>>>>
>>>>> -  if (Subtarget->isTargetWindows() && !Subtarget->isTargetCygMing() &&
>>>>> +  if (Subtarget->isTargetKnownWindowsMSVC() &&
>>>>> !Subtarget->isTargetCygMing() &&
>>>>>        MMI->usesVAFloatArgument()) {
>>>>>      StringRef SymbolName = Subtarget->is64Bit() ? "_fltused" :
>>>>> "__fltused";
>>>>>      MCSymbol *S = MMI->getContext().GetOrCreateSymbol(SymbolName);
>>>>> @@ -681,12 +681,12 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
>>>>>        OutStreamer.SwitchSection(TLOFCOFF.getDrectveSection());
>>>>>        SmallString<128> name;
>>>>>        for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e;
>>>>> ++i) {
>>>>> -        if (Subtarget->isTargetWindows())
>>>>> +        if (Subtarget->isTargetKnownWindowsMSVC())
>>>>>            name = " /EXPORT:";
>>>>>          else
>>>>>            name = " -export:";
>>>>>          name += DLLExportedGlobals[i]->getName();
>>>>> -        if (Subtarget->isTargetWindows())
>>>>> +        if (Subtarget->isTargetKnownWindowsMSVC())
>>>>>            name += ",DATA";
>>>>>          else
>>>>>          name += ",data";
>>>>> @@ -694,7 +694,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
>>>>>        }
>>>>>
>>>>>        for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) {
>>>>> -        if (Subtarget->isTargetWindows())
>>>>> +        if (Subtarget->isTargetKnownWindowsMSVC())
>>>>>            name = " /EXPORT:";
>>>>>          else
>>>>>            name = " -export:";
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Apr  1 13:15:34 2014
>>>>> @@ -876,7 +876,7 @@ bool X86FastISel::X86SelectRet(const Ins
>>>>>    // a virtual register in the entry block, so now we copy the value
>>>>> out
>>>>>    // and into %rax. We also do the same with %eax for Win32.
>>>>>    if (F.hasStructRetAttr() &&
>>>>> -      (Subtarget->is64Bit() || Subtarget->isTargetWindows())) {
>>>>> +      (Subtarget->is64Bit() ||
>>>>> Subtarget->isTargetKnownWindowsMSVC())) {
>>>>>      unsigned Reg = X86MFInfo->getSRetReturnReg();
>>>>>      assert(Reg &&
>>>>>             "SRetReturnReg should have been set in
>>>>> LowerFormalArguments()!");
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Apr  1 13:15:34
>>>>> 2014
>>>>> @@ -189,7 +189,7 @@ static TargetLoweringObjectFile *createT
>>>>>      return new X86LinuxTargetObjectFile();
>>>>>    if (Subtarget->isTargetELF())
>>>>>      return new TargetLoweringObjectFileELF();
>>>>> -  if (Subtarget->isTargetWindows())
>>>>> +  if (Subtarget->isTargetKnownWindowsMSVC())
>>>>>      return new X86WindowsTargetObjectFile();
>>>>>    if (Subtarget->isTargetCOFF())
>>>>>      return new TargetLoweringObjectFileCOFF();
>>>>> @@ -250,7 +250,7 @@ void X86TargetLowering::resetOperationAc
>>>>>        addBypassSlowDiv(64, 16);
>>>>>    }
>>>>>
>>>>> -  if (Subtarget->isTargetWindows() && !Subtarget->isTargetCygMing()) {
>>>>> +  if (Subtarget->isTargetKnownWindowsMSVC() &&
>>>>> !Subtarget->isTargetCygMing()) {
>>>>>      // Setup Windows compiler runtime calls.
>>>>>      setLibcallName(RTLIB::SDIV_I64, "_alldiv");
>>>>>      setLibcallName(RTLIB::UDIV_I64, "_aulldiv");
>>>>> @@ -1906,7 +1906,7 @@ X86TargetLowering::LowerReturn(SDValue C
>>>>>    // We saved the argument into a virtual register in the entry block,
>>>>>    // so now we copy the value out and into %rax/%eax.
>>>>>    if (DAG.getMachineFunction().getFunction()->hasStructRetAttr() &&
>>>>> -      (Subtarget->is64Bit() || Subtarget->isTargetWindows())) {
>>>>> +      (Subtarget->is64Bit() ||
>>>>> Subtarget->isTargetKnownWindowsMSVC())) {
>>>>>      MachineFunction &MF = DAG.getMachineFunction();
>>>>>      X86MachineFunctionInfo *FuncInfo =
>>>>> MF.getInfo<X86MachineFunctionInfo>();
>>>>>      unsigned Reg = FuncInfo->getSRetReturnReg();
>>>>> @@ -2291,7 +2291,7 @@ X86TargetLowering::LowerFormalArguments(
>>>>>    // Save the argument into a virtual register so that we can access
>>>>> it
>>>>>    // from the return points.
>>>>>    if (MF.getFunction()->hasStructRetAttr() &&
>>>>> -      (Subtarget->is64Bit() || Subtarget->isTargetWindows())) {
>>>>> +      (Subtarget->is64Bit() ||
>>>>> Subtarget->isTargetKnownWindowsMSVC())) {
>>>>>      X86MachineFunctionInfo *FuncInfo =
>>>>> MF.getInfo<X86MachineFunctionInfo>();
>>>>>      unsigned Reg = FuncInfo->getSRetReturnReg();
>>>>>      if (!Reg) {
>>>>> @@ -8494,7 +8494,7 @@ X86TargetLowering::LowerGlobalTLSAddress
>>>>>                                Chain.getValue(1));
>>>>>    }
>>>>>
>>>>> -  if (Subtarget->isTargetWindows() || Subtarget->isTargetMingw()) {
>>>>> +  if (Subtarget->isTargetKnownWindowsMSVC() ||
>>>>> Subtarget->isTargetMingw()) {
>>>>>      // Just use the implicit TLS architecture
>>>>>      // Need to generate someting similar to:
>>>>>      //   mov     rdx, qword [gs:abs 58H]; Load pointer to
>>>>> ThreadLocalStorage
>>>>> @@ -15882,7 +15882,7 @@ X86TargetLowering::EmitLoweredWinAlloca(
>>>>>      }
>>>>>    } else {
>>>>>      const char *StackProbeSymbol =
>>>>> -      Subtarget->isTargetWindows() ? "_chkstk" : "_alloca";
>>>>> +      Subtarget->isTargetKnownWindowsMSVC() ? "_chkstk" : "_alloca";
>>>>>
>>>>>      BuildMI(*BB, MI, DL, TII->get(X86::CALLpcrel32))
>>>>>        .addExternalSymbol(StackProbeSymbol)
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Apr  1 13:15:34
>>>>> 2014
>>>>> @@ -756,7 +756,7 @@ namespace llvm {
>>>>>      /// isTargetFTOL - Return true if the target uses the MSVC _ftol2
>>>>> routine
>>>>>      /// for fptoui.
>>>>>      bool isTargetFTOL() const {
>>>>> -      return Subtarget->isTargetWindows() && !Subtarget->is64Bit();
>>>>> +      return Subtarget->isTargetKnownWindowsMSVC() &&
>>>>> !Subtarget->is64Bit();
>>>>>      }
>>>>>
>>>>>      /// isIntegerTypeFTOL - Return true if the MSVC _ftol2 routine
>>>>> should be
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue Apr  1 13:15:34 2014
>>>>> @@ -343,7 +343,7 @@ public:
>>>>>    bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
>>>>>    bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
>>>>>    bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
>>>>> -  bool isTargetWindows() const {
>>>>> +  bool isTargetKnownWindowsMSVC() const {
>>>>>      return TargetTriple.isKnownWindowsMSVCEnvironment();
>>>>>    }
>>>>>    bool isTargetMingw() const { return
>>>>> TargetTriple.isWindowsGNUEnvironment(); }
>>>>> @@ -359,7 +359,7 @@ public:
>>>>>    }
>>>>>
>>>>>    bool isTargetWin32() const {
>>>>> -    return !In64BitMode && (isTargetCygMing() || isTargetWindows());
>>>>> +    return !In64BitMode && (isTargetCygMing() ||
>>>>> isTargetKnownWindowsMSVC());
>>>>>    }
>>>>>
>>>>>    bool isPICStyleSet() const { return PICStyle != PICStyles::None; }
>>>>>
>>>>> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>>>>> URL:
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=205338&r1=205337&r2=205338&view=diff
>>>>>
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
>>>>> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Apr  1 13:15:34
>>>>> 2014
>>>>> @@ -39,7 +39,7 @@ static std::string computeDataLayout(con
>>>>>      Ret += "-p:32:32";
>>>>>
>>>>>    // Some ABIs align 64 bit integers and doubles to 64 bits, others
>>>>> to 32.
>>>>> -  if (ST.is64Bit() || ST.isTargetCygMing() || ST.isTargetWindows() ||
>>>>> +  if (ST.is64Bit() || ST.isTargetCygMing() ||
>>>>> ST.isTargetKnownWindowsMSVC() ||
>>>>>        ST.isTargetNaCl())
>>>>>      Ret += "-i64:64";
>>>>>    else
>>>>> @@ -60,7 +60,7 @@ static std::string computeDataLayout(con
>>>>>      Ret += "-n8:16:32";
>>>>>
>>>>>    // The stack is aligned to 32 bits on some ABIs and 128 bits on
>>>>> others.
>>>>> -  if (!ST.is64Bit() && (ST.isTargetCygMing() || ST.isTargetWindows()))
>>>>> +  if (!ST.is64Bit() && (ST.isTargetCygMing() ||
>>>>> ST.isTargetKnownWindowsMSVC()))
>>>>>      Ret += "-S32";
>>>>>    else
>>>>>      Ret += "-S128";
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Saleem Abdulrasool
>>>> compnerd (at) compnerd (dot) org
>>>>
>>>
>>
>>
>> --
>> Saleem Abdulrasool
>> compnerd (at) compnerd (dot) org
>>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140405/59917bb4/attachment.html>


More information about the llvm-commits mailing list