brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 18263be Raw
103 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -ast-dump %s | FileCheck %s2 3// CHECK: FunctionDecl {{.*}} used branch 'int (int)'4// CHECK: AttributedStmt5// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} branch6export int branch(int X){7    int resp;8    [branch] if (X > 0) {9        resp = -X;10    } else {11        resp = X * 2;12    }13 14    return resp;15}16 17// CHECK: FunctionDecl {{.*}} used flatten 'int (int)'18// CHECK: AttributedStmt19// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} flatten20export int flatten(int X){21    int resp;22    [flatten] if (X > 0) {23        resp = -X;24    } else {25        resp = X * 2;26    }27 28    return resp;29}30 31// CHECK: FunctionDecl {{.*}} used no_attr 'int (int)'32// CHECK-NOT: AttributedStmt33// CHECK-NOT: HLSLControlFlowHintAttr34export int no_attr(int X){35    int resp;36    if (X > 0) {37        resp = -X;38    } else {39        resp = X * 2;40    }41 42    return resp;43}44 45// CHECK: FunctionDecl {{.*}} used flatten_switch 'int (int)'46// CHECK: AttributedStmt47// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} flatten48export int flatten_switch(int X){49    int resp;50    [flatten] 51    switch (X) {52        case 0:53        resp = -X;54        break;55    case 1:56         resp = X+X;57        break;58    case 2:59        resp = X * X; break;60    }61 62    return resp;63}64 65// CHECK: FunctionDecl {{.*}} used branch_switch 'int (int)'66// CHECK: AttributedStmt67// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} branch68export int branch_switch(int X){69    int resp;70    [branch] 71    switch (X) {72     case 0:73        resp = -X;74        break;75    case 1:76        resp = X+X;77        break;78    case 2:79        resp = X * X; break;80    }81 82    return resp;83}84 85// CHECK: FunctionDecl {{.*}} used no_attr_switch 'int (int)'86// CHECK-NOT: AttributedStmt87// CHECK-NOT: HLSLControlFlowHintAttr88export int no_attr_switch(int X){89    int resp;90    switch (X) {91        case 0:92        resp = -X;93        break;94    case 1:95         resp = X+X;96        break;97    case 2:98        resp = X * X; break;99    }100 101    return resp;102}103