Home | History | Annotate | Download | only in CodeGenObjC
      1 // RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -O2 -disable-llvm-optzns -o - %s | FileCheck %s
      2 
      3 #import "nsvalue-boxed-expressions-support.h"
      4 
      5 // CHECK:      [[CLASS:@.*]]        = external global %struct._class_t
      6 // CHECK:      [[NSVALUE:@.*]]      = {{.*}}[[CLASS]]{{.*}}
      7 // CHECK:      [[RANGE_STR:.*]]     = {{.*}}_NSRange=II{{.*}}
      8 // CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithBytes:objCType:{{.*}}
      9 // CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
     10 // CHECK:      [[POINT_STR:.*]]     = {{.*}}CGPoint=dd{{.*}}
     11 // CHECK:      [[SIZE_STR:.*]]      = {{.*}}CGSize=dd{{.*}}
     12 // CHECK:      [[RECT_STR:.*]]      = {{.*}}CGRect={CGPoint=dd}{CGSize=dd}}{{.*}}
     13 // CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
     14 
     15 // CHECK-LABEL: define void @doRange()
     16 void doRange() {
     17   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRange{{.*}}
     18   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRange{{.*}}
     19   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
     20   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
     21   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
     22   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
     23   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
     24   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
     25   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
     26   NSRange ns_range = { .location = 0, .length = 42 };
     27   // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
     28   NSValue *range = @(ns_range);
     29   // CHECK:      ret void
     30 }
     31 
     32 // CHECK-LABEL: define void @doPoint()
     33 void doPoint() {
     34   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGPoint{{.*}}
     35   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGPoint{{.*}}
     36   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
     37   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
     38   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGPoint* [[LOCAL_VAR]]{{.*}}
     39   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
     40   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
     41   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
     42   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
     43   CGPoint cg_point = { .x = 42, .y = 24 };
     44   // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}})
     45   NSValue *point = @(cg_point);
     46   // CHECK:      ret void
     47 }
     48 
     49 // CHECK-LABEL: define void @doSize()
     50 void doSize() {
     51   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGSize{{.*}}
     52   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGSize{{.*}}
     53   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
     54   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
     55   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGSize* [[LOCAL_VAR]]{{.*}}
     56   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
     57   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
     58   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
     59   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
     60   CGSize cg_size = { .width = 42, .height = 24 };
     61   // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}})
     62   NSValue *size = @(cg_size);
     63   // CHECK:      ret void
     64 }
     65 
     66 // CHECK-LABEL: define void @doRect()
     67 void doRect() {
     68   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGRect{{.*}}
     69   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGRect{{.*}}
     70   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
     71   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
     72   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGRect* [[LOCAL_VAR]]{{.*}}
     73   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
     74   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
     75   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
     76   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
     77   CGPoint cg_point = { .x = 42, .y = 24 };
     78   CGSize cg_size = { .width = 42, .height = 24 };
     79   CGRect cg_rect = { .origin = cg_point, .size = cg_size };
     80   // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
     81   NSValue *rect = @(cg_rect);
     82   // CHECK:      ret void
     83 }
     84 
     85 // CHECK-LABEL: define void @doNSEdgeInsets()
     86 void doNSEdgeInsets() {
     87   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
     88   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
     89   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
     90   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
     91   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
     92   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
     93   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
     94   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
     95   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
     96   NSEdgeInsets ns_edge_insets;
     97   // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
     98   NSValue *edge_insets = @(ns_edge_insets);
     99   // CHECK:      ret void
    100 }
    101 
    102 // CHECK-LABEL: define void @doRangeRValue() 
    103 void doRangeRValue() {
    104   // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
    105   // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
    106   // CHECK:     call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}}
    107   // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
    108   // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
    109   // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
    110   // CHECK:     call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
    111   NSValue *range_rvalue = @(getRange());
    112   // CHECK: ret void
    113 }
    114 
    115