// Copyright 2023 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

namespace iree.instruments;

// IREE Instrument DataBase for Dispatches.
file_identifier "IDBD";
file_extension "fb";

table DispatchFunctionDef {
  // MLIR symbol name of the exported function.
  name:string;
  // Target executable configuration attribute.
  target:string;
  // Pipeline layout string.
  layout:string;
  // Function source code.
  source:string;
  // TODO(benvanik): other structural information from the IR like bindings.
}

// A unique dispatch site within the program.
// Many dispatch sites may dispatch the same function.
// Note that dispatch sites may not be unique within the instrument stream as
// loops and repeated function calls may cause the same dispatch site to be
// reached many times.
table DispatchSiteDef {
  // Dispatched function ordinal in the function table.
  function:uint32;
}

table DispatchInstrumentDef {
  // 0 today - not stable!
  version:uint32;
  // Reserved.
  flags:uint32;
  // All functions referenced by ordinal in their original module order.
  functions:[DispatchFunctionDef];
  // All unique dispatch sites within the program.
  sites:[DispatchSiteDef];
}

root_type DispatchInstrumentDef;
