Skip to content

Commit 0277f08

Browse files
committed
[flang] Inherit target specific code for BIND(C) types on Windows
Inherit target specific code for Windows i386 and x86_64 from the classes that define that code for the respective processors on non-Windows operating systems. Only overload parts that differ. That allows re-using the existing implementation for BIND(C) types on non-Windows x86_64 also for Windows x86_64 targets. Fixes #114035.
1 parent 4f469ae commit 0277f08

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

flang/lib/Optimizer/CodeGen/Target.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,8 @@ struct TargetI386 : public GenericTarget<TargetI386> {
199199
//===----------------------------------------------------------------------===//
200200

201201
namespace {
202-
struct TargetI386Win : public GenericTarget<TargetI386Win> {
203-
using GenericTarget::GenericTarget;
204-
205-
static constexpr int defaultWidth = 32;
202+
struct TargetI386Win : public TargetI386 {
203+
using TargetI386::TargetI386;
206204

207205
CodeGenSpecifics::Marshalling
208206
complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override {
@@ -718,10 +716,8 @@ struct TargetX86_64 : public GenericTarget<TargetX86_64> {
718716
//===----------------------------------------------------------------------===//
719717

720718
namespace {
721-
struct TargetX86_64Win : public GenericTarget<TargetX86_64Win> {
722-
using GenericTarget::GenericTarget;
723-
724-
static constexpr int defaultWidth = 64;
719+
struct TargetX86_64Win : public TargetX86_64 {
720+
using TargetX86_64::TargetX86_64;
725721

726722
CodeGenSpecifics::Marshalling
727723
complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override {

flang/test/Fir/struct-passing-x86-64-several-fields-inreg.fir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// struct has more than one field.
33
// REQUIRES: x86-registered-target
44
// RUN: fir-opt -target-rewrite="target=x86_64-unknown-linux-gnu" %s -o - | FileCheck %s
5+
// RUN: fir-opt -target-rewrite="target=x86_64-w64-windows-gnu" %s -o - | FileCheck %s
56

67

78
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {

flang/test/Fir/target-rewrite-boxchar.fir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: fir-opt --target-rewrite="target=i386-unknown-linux-gnu" %s | FileCheck %s --check-prefix=INT32
22
// RUN: fir-opt --target-rewrite="target=x86_64-unknown-linux-gnu" %s | FileCheck %s --check-prefix=INT64
3+
// RUN: fir-opt --target-rewrite="target=x86_64-w64-windows-gnu" %s | FileCheck %s --check-prefix=INT64
34
// RUN: fir-opt --target-rewrite="target=aarch64-unknown-linux-gnu" %s | FileCheck %s --check-prefix=INT64
45
// RUN: fir-opt --target-rewrite="target=powerpc64le-unknown-linux-gnu" %s | FileCheck %s --check-prefix=INT64
56
// RUN: fir-opt --target-rewrite="target=amdgcn-amd-amdhsa" %s | FileCheck %s --check-prefix=INT64

0 commit comments

Comments
 (0)