[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-22 Thread Alex Langford via Phabricator via cfe-commits
bulbazord requested changes to this revision.
bulbazord added a comment.

In D157497#4592330 , @Pivnoy wrote:

> At the moment, the TargetParser architecture is extensible. This complicates 
> the addition of new architectures, operating systems, and so on.
> In the main discussion, it was proposed to redesign the architecture of this 
> module in order to increase the possibility of adding new architectures, etc.
> The main idea of   the rework was to separate the Triple entity into a 
> data-class, and create a number of interfaces from components that would 
> include Triple, through the implementation of which it would be possible to 
> represent various data bindings of the components. At the moment, Triple is 
> overflowing with various methods that do not fully meet the ideas of OOP.
> Since the TargetParser module is quite large and has many dependencies 
> throughout the llvm-project, it was first of all supposed to remove these 
> methods from Triple, since they would not correspond to OOP ideas.
> This would help to gradually rid Triple of unnecessary dependencies, and 
> gradually change the architecture inside Triple, without breaking code of 
> another LLVM developers.

I'm still not sure how this would make things simpler. I'll be as specific is 
possible in what does not click for me.

There is an inherent complexity in parsing triples. Architectures can have 
variants and subvariants, compilers and other tools do different things for the 
same architecture and OS when there are different vendors, the environment can 
subtly change things like ABI, the list goes on. I don't think you're going to 
be able to wholesale reduce complexity here. The proposal you've laid out here 
is certainly very OOP-like (in some sense of the phrase "OOP") but you present 
your ideas under the assumption that this style of OOP is the ideal to strive 
for. Why is that? Why is this better than what exists today? Is it easier to 
debug? Is it more performant? Is it easier to maintain? I personally do not 
think it will be better than what already exists in any of those ways.

In the original discourse thread, you also made the argument that the potential 
performance overhead and binary size increase should be unnoticeable and that 
with modern machines we do not need to fight for each microsecond. Without any 
numbers for performance or size, this is not an argument I can accept. 
Knowingly adding a performance/size regression to your build tools without an 
appropriate tradeoff does not make sense to do.

If you want to do this, please provide a concrete argument for what benefit 
this brings.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-22 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: StephenFan.

This change looks strictly worse in isolation, the proposal on discourse did 
not reach consensus, and looking at the diagram in 
https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11 there 
is zero chance that it is ever going to be accepted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-22 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy added a comment.
Herald added a subscriber: sunshaoce.

@bulbazord 
@MaskRay


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-16 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy added a comment.

At the moment, the TargetParser architecture is extensible. This complicates 
the addition of new architectures, operating systems, and so on.
In the main discussion, it was proposed to redesign the architecture of this 
module in order to increase the possibility of adding new architectures, etc.
The main idea of   the rework was to separate the Triple entity into a 
data-class, and create a number of interfaces from components that would 
include Triple, through the implementation of which it would be possible to 
represent various data bindings of the components. At the moment, Triple is 
overflowing with various methods that do not fully meet the ideas of OOP.
Since the TargetParser module is quite large and has many dependencies 
throughout the llvm-project, it was first of all supposed to remove these 
methods from Triple, since they would not correspond to OOP ideas.
This would help to gradually rid Triple of unnecessary dependencies, and 
gradually change the architecture inside Triple, without breaking code of 
another LLVM developers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Alex Langford via Phabricator via cfe-commits
bulbazord added a comment.

In D157497#4586165 , @MaskRay wrote:

> In D157497#4584621 , @Pivnoy wrote:
>
>> This discussion was the main motivation for this change.
>> https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11
>> As a result, Triple should become a data class, and its dependencies such as 
>> Architecture, Operating System etc. represent in the form of interfaces that 
>> can be implemented for the necessary instances.
>
> FWIW I still don't see advantages by switching to the new 
> `llvm::TripleUtils::isArch32Bit` style. How is it better than the current way?

+1
What advantages does this approach bring? I re-read the RFC in the discourse 
link you posted and I'm still not sure why this approach is desirable. Happy to 
discuss further either on this PR or in the discourse thread.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D157497#4584621 , @Pivnoy wrote:

> This discussion was the main motivation for this change.
> https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11
> As a result, Triple should become a data class, and its dependencies such as 
> Architecture, Operating System etc. represent in the form of interfaces that 
> can be implemented for the necessary instances.

FWIW I still don't see advantages by switching to the new 
`llvm::TripleUtils::isArch32Bit` style. How is it better than the current way?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy added a comment.

This discussion was the main motivation for this change.
https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11
As a result, Triple should become a data class, and its dependencies such as 
Architecture, Operating System etc. represent in the form of interfaces that 
can be implemented for the necessary instances.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Is there some separate discussion thread or proposal about this refactoring and 
its motivations?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-13 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy updated this revision to Diff 549688.
Pivnoy added a comment.
Herald added subscribers: luke, pmatos, frasercrmck, luismarques, apazos, 
sameer.abuasal, pengfei, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, sabuasal, johnrusso, 
rbar, kbarton, jgravelle-google, arichardson, sbc100, nemanjai, dschuff, emaste.

Add test for isArch32Bit to TripleUtilsTest


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

Files:
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/include/llvm/TargetParser/TripleUtils.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/BinaryFormat/MachO.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/ProfileData/InstrProfCorrelator.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/TripleUtils.cpp
  llvm/lib/XRay/InstrumentationMap.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/unittests/TargetParser/TripleUtilsTest.cpp

Index: llvm/unittests/TargetParser/TripleUtilsTest.cpp
===
--- /dev/null
+++ llvm/unittests/TargetParser/TripleUtilsTest.cpp
@@ -0,0 +1,179 @@
+//===--- TripleUtils.cpp - TripleUtils unit tests
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/TargetParser/TripleUtils.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(TripleUtilsTest, CheckArchBitWidth) {
+  Triple T;
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::arm);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hexagon);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::msp430);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86_64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  

[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-12 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy updated this revision to Diff 549621.
Pivnoy added a comment.

Fix some format mistake


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/include/llvm/TargetParser/TripleUtils.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/TripleUtils.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/unittests/TargetParser/TripleUtilsTest.cpp

Index: llvm/unittests/TargetParser/TripleUtilsTest.cpp
===
--- /dev/null
+++ llvm/unittests/TargetParser/TripleUtilsTest.cpp
@@ -0,0 +1,116 @@
+//===--- TripleUtils.cpp - TripleUtils unit tests
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/TargetParser/TripleUtils.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(TripleUtilsTest, CheckArchBitWidth) {
+  Triple T;
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::arm);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hexagon);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::msp430);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86_64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparcel);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+  ;
+
+  T.setArch(Triple::sparcv9);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::avr);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::lanai);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::csky);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::dxil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::xtensa);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+}
+
+} // namespace
\ No newline at end of file
Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -1094,172 +1094,140 @@
 
 TEST(TripleTest, BitWidthPredicates) {
   Triple T;
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::arm);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::hexagon);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::mips);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::mips64);
-  

[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-12 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy updated this revision to Diff 549620.
Pivnoy added a comment.

Add deprecated attribute


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157497/new/

https://reviews.llvm.org/D157497

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/include/llvm/TargetParser/TripleUtils.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/TripleUtils.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/unittests/TargetParser/TripleUtilsTest.cpp

Index: llvm/unittests/TargetParser/TripleUtilsTest.cpp
===
--- /dev/null
+++ llvm/unittests/TargetParser/TripleUtilsTest.cpp
@@ -0,0 +1,116 @@
+//===--- TripleUtils.cpp - TripleUtils unit tests
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/TargetParser/TripleUtils.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(TripleUtilsTest, CheckArchBitWidth) {
+  Triple T;
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::arm);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hexagon);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::msp430);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86_64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparcel);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+  ;
+
+  T.setArch(Triple::sparcv9);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::avr);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::lanai);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::csky);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::dxil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::xtensa);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+}
+
+} // namespace
\ No newline at end of file
Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -1094,172 +1094,140 @@
 
 TEST(TripleTest, BitWidthPredicates) {
   Triple T;
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::arm);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::hexagon);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::mips);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::mips64);
-  

[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-09 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy created this revision.
Herald added subscribers: s.egerton, simoncook, asb, fedor.sergeev, hiraditya, 
rampitec.
Herald added a project: All.
Pivnoy requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wangpc, aheejin.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157497

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/include/llvm/TargetParser/TripleUtils.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/Triple.cpp
  llvm/lib/TargetParser/TripleUtils.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/unittests/TargetParser/TripleUtilsTest.cpp

Index: llvm/unittests/TargetParser/TripleUtilsTest.cpp
===
--- /dev/null
+++ llvm/unittests/TargetParser/TripleUtilsTest.cpp
@@ -0,0 +1,116 @@
+//===--- TripleUtils.cpp - TripleUtils unit tests
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/TargetParser/TripleUtils.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(TripleUtilsTest, CheckArchBitWidth) {
+  Triple T;
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::arm);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hexagon);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::msp430);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86_64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparc);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::sparcel);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+  ;
+
+  T.setArch(Triple::sparcv9);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::wasm64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::avr);
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::lanai);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::riscv64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::csky);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch32);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::loongarch64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::dxil);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::xtensa);
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+}
+
+} // namespace
\ No newline at end of file
Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -1094,172 +1094,140 @@
 
 TEST(TripleTest, BitWidthPredicates) {
   Triple T;
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::arm);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
 
   T.setArch(Triple::hexagon);
-  EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());