brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 6d80185 Raw
96 lines · cpp
1// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d \2// RUN:   -emit-llvm %s -o - | FileCheck %s3 4#include <stdint.h>5 6/// Ensure that fields inherited from a parent struct are treated in the same7/// way as fields directly in the child for the purposes of LoongArch ABI rules.8 9struct parent1_int32_s {10  int32_t i1;11};12 13struct child1_int32_s : parent1_int32_s {14  int32_t i2;15};16 17// CHECK-LABEL: define{{.*}} i64 @_Z30int32_int32_struct_inheritance14child1_int32_s(i64 %a.coerce)18struct child1_int32_s int32_int32_struct_inheritance(struct child1_int32_s a) {19  return a;20}21 22struct parent2_int32_s {23  int32_t i1;24};25 26struct child2_float_s : parent2_int32_s {27  float f1;28};29 30// CHECK-LABEL: define{{.*}} { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s(i32 %0, float %1)31struct child2_float_s int32_float_struct_inheritance(struct child2_float_s a) {32  return a;33}34 35struct parent3_float_s {36  float f1;37};38 39struct child3_int64_s : parent3_float_s {40  int64_t i1;41};42 43// CHECK-LABEL: define{{.*}} { float, i64 } @_Z30float_int64_struct_inheritance14child3_int64_s(float %0, i64 %1)44struct child3_int64_s float_int64_struct_inheritance(struct child3_int64_s a) {45  return a;46}47 48struct parent4_double_s {49  double d1;50};51 52struct child4_double_s : parent4_double_s {53  double d1;54};55 56// CHECK-LABEL: define{{.*}} { double, double } @_Z32double_double_struct_inheritance15child4_double_s(double %0, double %1)57struct child4_double_s double_double_struct_inheritance(struct child4_double_s a) {58  return a;59}60 61/// When virtual inheritance is used, the resulting struct isn't eligible for62/// passing in registers.63 64struct parent5_virtual_s {65  int32_t i1;66};67 68struct child5_virtual_s : virtual parent5_virtual_s {69  float f1;70};71 72// CHECK-LABEL: define{{.*}} void @_ZN16child5_virtual_sC1EOS_(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr noundef nonnull align 8 dereferenceable(12) %0)73struct child5_virtual_s int32_float_virtual_struct_inheritance(struct child5_virtual_s a) {74  return a;75}76 77/// Check for correct lowering in the presence of diamond inheritance.78 79struct parent6_float_s {80  float f1;81};82 83struct child6a_s : parent6_float_s {84};85 86struct child6b_s : parent6_float_s {87};88 89struct grandchild_6_s : child6a_s, child6b_s {90};91 92// CHECK-LABEL: define{{.*}} { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(float %0, float %1)93struct grandchild_6_s float_float_diamond_struct_inheritance(struct grandchild_6_s a) {94  return a;95}96