[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-12-06 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 392071.
jozefl marked an inline comment as done.
jozefl added a comment.

Thanks, good point, fixed in the attached patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: "-target-feature" 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-12-02 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:223-224
+  MCUData LoadedMCUData;
+  if (const Arg *MCUArg = Args.getLastArg(options::OPT_mmcu_EQ))
+LoadedMCUData = getMCUData(MCUArg->getValue());
+

It might be worth moving this under `hwmult` option check, so we do not need to 
load MCU data again if the option is properly specificed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-11-15 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-10-28 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-10-18 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-10-12 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 379011.
jozefl added a comment.

Rebase onto new base revision to fix pre-merge tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: "-target-feature" "+hwmult32"
 // CHECK-NOT: 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-10-04 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-28 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 375666.
jozefl marked 5 inline comments as done.
jozefl added a comment.

Thanks, good points, I have addressed them in this updated patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-28 Thread Anton Korobeynikov via Phabricator via cfe-commits
asl requested changes to this revision.
asl added a comment.
This revision now requires changes to proceed.

Please see comments inline




Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:43
+/// std::lower_bound is used to perform an efficient binary search on the data.
+static MCUData loadMCUData(const StringRef MCU) {
+  const MCUData MSP430MCUData[612] = {

maybe it would be better to use `get` instead of `load` here?



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:77
+static void processHWMultFeatures(const Driver , const ArgList ,
+  std::vector ,
+  StringRef SupportedHWMult) {

`Features` is effectively an output argument here. Can it be last argument? 
Maybe it would be better to name `addHWMultFeatures`, overall the function just 
adds them and do not touch existing things in the `Features` vector?



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:110
 
-  if (MCU && SupportedHWMult == "none")
-D.Diag(clang::diag::warn_drv_msp430_hwmult_unsupported) << HWMult;
-  if (MCU && HWMult != SupportedHWMult)
-D.Diag(clang::diag::warn_drv_msp430_hwmult_mismatch)
-<< SupportedHWMult << HWMult;
-
-  if (HWMult == "16bit") {
-// '16bit' - for 16-bit only hw multiplier.
+  if (HWMult == "16bit")
 Features.push_back("+hwmult16");

StringSwitch?



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:44
+static MCUData loadMCUData(const StringRef MCU) {
+  const MCUData MSP430MCUData[612] = {
+#define MSP430_MCU(NAME, CPU, HWMULT) {(NAME), (CPU), (HWMULT)},

Can we simply use `MSP430MCUData[]` here in order not to fix multiple places 
when new MCU is added?



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:47
 #include "clang/Basic/MSP430Target.def"
-  .Default("none");
-}
+  };
 

I'd also #undef here for the sake of not polluting everything with extra macros


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-22 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 374255.
jozefl added a comment.

Undo incorrect rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: "-target-feature" "+hwmult32"
 // CHECK-NOT: "-target-feature" "+hwmultf5"
 
-// RUN: 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-22 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 374200.
jozefl added a comment.
Herald added subscribers: llvm-commits, ormris, hiraditya.
Herald added a project: LLVM.

Rebase to fix patch application failure for
clang/test/Misc/target-invalid-cpu-note.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/MSP430.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/msp430-cpu.c
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/msp430-defs.c
  llvm/lib/Target/MSP430/MSP430.td
  llvm/lib/Target/MSP430/MSP430Subtarget.cpp
  llvm/lib/Target/MSP430/MSP430Subtarget.h
  llvm/test/CodeGen/MSP430/build-attrs.ll

Index: llvm/test/CodeGen/MSP430/build-attrs.ll
===
--- llvm/test/CodeGen/MSP430/build-attrs.ll
+++ llvm/test/CodeGen/MSP430/build-attrs.ll
@@ -8,6 +8,8 @@
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430,SMALL
 ; RUN: llc -mtriple=msp430 -mcpu=msp430x -filetype=obj < %s \
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
+; RUN: llc -mtriple=msp430 -mcpu=msp430xv2 -filetype=obj < %s \
+; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
 
 ; COMMON: BuildAttributes {
 ; COMMON: FormatVersion: 0x41
Index: llvm/lib/Target/MSP430/MSP430Subtarget.h
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.h
+++ llvm/lib/Target/MSP430/MSP430Subtarget.h
@@ -36,7 +36,7 @@
 
 private:
   virtual void anchor();
-  bool ExtendedInsts = false;
+  bool MSP430X = false;
   HWMultEnum HWMultMode = NoHWMult;
   MSP430FrameLowering FrameLowering;
   MSP430InstrInfo InstrInfo;
@@ -60,6 +60,8 @@
   bool hasHWMult32() const { return HWMultMode == HWMult32; }
   bool hasHWMultF5() const { return HWMultMode == HWMultF5; }
 
+  bool hasMSP430X() const { return MSP430X; }
+
   const TargetFrameLowering *getFrameLowering() const override {
 return 
   }
Index: llvm/lib/Target/MSP430/MSP430Subtarget.cpp
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.cpp
+++ llvm/lib/Target/MSP430/MSP430Subtarget.cpp
@@ -40,9 +40,6 @@
 
 MSP430Subtarget &
 MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
-  ExtendedInsts = false;
-  HWMultMode = NoHWMult;
-
   StringRef CPUName = CPU;
   if (CPUName.empty())
 CPUName = "msp430";
Index: llvm/lib/Target/MSP430/MSP430.td
===
--- llvm/lib/Target/MSP430/MSP430.td
+++ llvm/lib/Target/MSP430/MSP430.td
@@ -18,8 +18,8 @@
 // Subtarget Features. 
 //===--===//
 def FeatureX
- : SubtargetFeature<"ext", "ExtendedInsts", "true",
-"Enable MSP430-X extensions">;
+ : SubtargetFeature<"msp430x", "MSP430X", "true",
+"Enable MSP430X extensions">;
 
 def FeatureHWMult16
  : SubtargetFeature<"hwmult16", "HWMultMode", "HWMult16",
@@ -42,6 +42,7 @@
 def : Proc<"generic", []>;
 def : Proc<"msp430",  []>;
 def : Proc<"msp430x", [FeatureX]>;
+def : Proc<"msp430xv2",   [FeatureX]>;
 
 //===--===//
 // Register File Description
Index: clang/test/Preprocessor/msp430-defs.c
===
--- /dev/null
+++ clang/test/Preprocessor/msp430-defs.c
@@ -0,0 +1,20 @@
+// Check the correct macros are defined for each CPU.
+
+// RUN: %clang -target msp430 -x c -E -dM %s -o - | FileCheck  %s
+// RUN: %clang -target msp430 -mcpu=generic -x c -E -dM %s -o - | FileCheck %s
+// RUN: %clang -target msp430 -mcpu=msp430 -x c -E -dM %s -o - | FileCheck %s
+
+// CHECK: MSP430
+// CHECK: __ELF__
+// CHECK-NOT: __MSP430X__
+// CHECK: __MSP430__
+
+// RUN: %clang -target msp430 -mcpu=msp430x -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+// RUN: %clang -target msp430 -mcpu=msp430xv2 -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+
+// MSP430X: MSP430
+// MSP430X: __ELF__
+// MSP430X: __MSP430X__
+// MSP430X: __MSP430__
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -209,3 +209,7 @@
 // RUN: not %clang_cc1 -triple riscv64 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-09-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-31 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Pinging for review.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-24 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 368348.
jozefl added a comment.

Here's an updated patch that fixes some minor nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: "-target-feature" "+hwmult32"
 // CHECK-NOT: "-target-feature" 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367805.
jozefl added a comment.

Here's an updated patch to fix the win64 failure.

MSVC can't handle the conversion from a ForwardIterator to a const pointer when
the container being searched with std::lower_bound is a std::array. Meanwhile
clang-tidy warns when the type assigned to with the return value of
std::lower_bound is not a pointer, so I can't just change the type declaration
to a lone "auto", and surpressing the clang-tidy warning for this warning
doesn't seem like the best option either.

So I've changed the data type used to store the MCUData to a C-style array, and
also moved its definition into loadMCUData.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-20 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367739.
jozefl added a comment.

Here's an updated patch that stores the HWMult and CPU data for each MCU as
strings instead of enums. This simplifies the patch as string conversions to
and from enums are no longer required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-19 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Now that I am in the process of implementing the processing of the "CPU"
feature, I've realized the decision to store the CPU and HWMult information as
enums instead of strings has some downsides that may outweigh the benefits:

- All string values passed to options need to be first converted to enums 
before they can be processed
- Enums need to be converted back to strings in for use in diagnostics
- Additional code is required to perform these conversions

If all CPU and HWMult features are stored as strings, no conversions are
necessary, and the overall amount of code that needs to change for this MCU
data update is small.

As mentioned in the original commit message, the benefits of using enums are
that we have a canonical "invalid" value for when the user input is invalid,
and the hard-coded data is guaranteed to be valid (but not necessarily
correct) since all enums used to define features must be defined.

The processing of the CPU feature is much simpler than the hwmult features,
which is why all the conversions to and from enums seem even more unnecessary
now.

What do you think @asl? Should I get rid of the enums?
That is was I'm leaning towards right now.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-19 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367458.
jozefl added a comment.

Fixed clang-tidy warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck 

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-18 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl created this revision.
jozefl added a reviewer: asl.
jozefl requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch updates MSP430 MCU data to the latest version distributed by
TI, adding support for 451 additional MCUs.

The hardware multiply version supported by each MCU is now stored as an
enum in the MCU data file, rather than a string. The string value passed
to the -mhwmult= option is now also converted to an enum. Using an enum
simplifies the processing of values, as invalid user input can be
canonicalized as a descriptive enum. It also ensures that the hard-coded
MCU data is valid; that there are no values that the parser does not
recognize.

Clang will no longer explicitly disable hwmult features for MCUs that
don't have hardware multiply support, as hwmult feature are already
disabled by default.

The CPU version of each MCU is now stored with the hard-coded MCU data,
so Clang can enable the appropriate LLVM CPU features when a particular
MCU is selected.

The hard-coded MCU data is stored in lexicographic order, which enables
efficient searching of the data with binary search, using
std::lower_bound.

If the patch is acceptable, I would appreciate it if someone would apply
it for me, as I do not have commit access.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+//