brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 1ce8b39 Raw
35 lines · plain
1// RUN: %offload-tblgen -gen-print-header -I %S/../../../liboffload/API %s | %fcheck-generic2 3// Check that ranged function parameters are implemented correctly. These4// are pointers to an array of an arbitrary size. Their size is described as a5// range between two values. This is typically between 0 and a parameter such6// as NumItems. The range information helps the printing code print the entire7// range of the output rather than just the pointer or the first element.8 9include "APIDefs.td"10 11def some_handle_t : Handle {12    let desc = "An example handle type";13}14 15def FunctionA : Function {16    let desc = "Function A description";17    let details = [ "Function A detailed information" ];18  let params = [19    Param<"size_t", "OutCount", "the number of things to write out", PARAM_IN>,20    RangedParam<"some_handle_t*", "OutPtr", "pointer to the output things.", PARAM_OUT,21      Range<"0", "OutCount">>22  ];23  let returns = [];24}25 26// CHECK: inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const struct function_a_params_t *params) {27// CHECK:   os << ".OutPtr = ";28// CHECK:   for (size_t i = 0; i < *params->pOutCount; i++) {29// CHECK:     if (i > 0) {30// CHECK:       os << ", ";31// CHECK:     }32// CHECK:     printPtr(os, (*params->pOutPtr)[i]);33// CHECK:   }34// CHECK:   os << "}";35