summaryrefslogtreecommitdiff
path: root/lib/Target/TGSI/TGSI.h
blob: e394d1050ec2d7d5386c5e43dfc852cd5913775e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//===-- TGSI.h - Top-level interface for TGSI representation --*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the entry points for global functions defined in the LLVM
// TGSI back-end.
//
//===----------------------------------------------------------------------===//

#ifndef TGSI_H
#define TGSI_H

#include "MCTargetDesc/TGSIMCTargetDesc.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetMachine.h"
#include <cassert>

namespace llvm {
   class FunctionPass;
   class TGSITargetMachine;

   FunctionPass *createTGSIISelDag(TGSITargetMachine &tm);
   FunctionPass *createTGSIBranchConvPass(const TGSITargetMachine &tm);

   namespace tgsi {
      enum AddressSpace {
         // Enums corresponding to OpenCL address spaces
         PRIVATE = 0,
         GLOBAL = 1,
         LOCAL = 2,
         CONSTANT = 3,
         // Special address space the arguments of a __kernel function are stored in
         INPUT = 4
      };
   }

#if 0
   namespace {
      inline bool isKernelFunction(const Function *f) {
         NamedMDNode *md = f->getParent()->getNamedMetadata("opencl.kernels");

         if (md) {
            printf("isKernelFunction found md with %d operands\n");
            for (unsigned i = 0; i < md->getNumOperands(); ++i) {
	       auto *metaData = dyn_cast<ConstantAsMetadata>(md->getOperand(i)->getOperand(0));

	       printf("isKernelFunction md %d %p\n", i, metaData);
	       assert(metaData);

	       Value *v = metaData->getValue();
               assert(v && isa<Function>(v));

               if (f == static_cast<Function *>(v))
                  return true;
            }
         }

         return false;
      }
   }
#endif
}
#endif