aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/llvm35/llvm-target.ads
blob: b7c35848a5cae00c71b7a23a780ee4f0dae77d29 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--  LLVM binding
--  Copyright (C) 2014 Tristan Gingold
--
--  GHDL is free software; you can redistribute it and/or modify it under
--  the terms of the GNU General Public License as published by the Free
--  Software Foundation; either version 2, or (at your option) any later
--  version.
--
--  GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
--  WARRANTY; without even the implied warranty of MERCHANTABILITY or
--  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--  for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with GHDL; see the file COPYING.  If not, write to the Free
--  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
--  02111-1307, USA.
with System;
with Interfaces; use Interfaces;
with Interfaces.C; use Interfaces.C;
with LLVM.Core; use LLVM.Core;

package LLVM.Target is

   type TargetDataRef is new System.Address;

   --  LLVMInitializeNativeTarget - The main program should call this function
   --  to initialize the native target corresponding to the host.  This is
   --  useful for JIT applications to ensure that the target gets linked in
   --  correctly.
   procedure InitializeNativeTarget;
   pragma Import (C, InitializeNativeTarget,
                  "LLVMInitializeNativeTarget_noinline");

   --  LLVMInitializeNativeTargetAsmPrinter - The main program should call this
   --  function to initialize the printer for the native target corresponding
   --  to the host.
   procedure InitializeNativeAsmPrinter;
   pragma Import (C, InitializeNativeAsmPrinter,
                  "LLVMInitializeNativeAsmPrinter_noinline");

   --  Creates target data from a target layout string.
   --  See the constructor llvm::DataLayout::DataLayout.
   function CreateTargetData (StringRep : Cstring) return TargetDataRef;
   pragma Import (C, CreateTargetData, "LLVMCreateTargetData");

   --  Adds target data information to a pass manager. This does not take
   --  ownership of the target data.
   --  See the method llvm::PassManagerBase::add.
   procedure AddTargetData(TD : TargetDataRef; PM : PassManagerRef);
   pragma Import (C, AddTargetData, "LLVMAddTargetData");

   --  Converts target data to a target layout string. The string must be
   --  disposed with LLVMDisposeMessage.
   --  See the constructor llvm::DataLayout::DataLayout. */
   function CopyStringRepOfTargetData(TD :TargetDataRef) return Cstring;
   pragma Import (C, CopyStringRepOfTargetData,
                  "LLVMCopyStringRepOfTargetData");

   --  Returns the pointer size in bytes for a target.
   --  See the method llvm::DataLayout::getPointerSize.
   function PointerSize(TD : TargetDataRef) return unsigned;
   pragma Import (C, PointerSize, "LLVMPointerSize");

   --  Computes the ABI size of a type in bytes for a target.
   --  See the method llvm::DataLayout::getTypeAllocSize.
   function ABISizeOfType (TD : TargetDataRef; Ty: TypeRef) return Unsigned_64;
   pragma Import (C, ABISizeOfType, "LLVMABISizeOfType");

   --  Computes the ABI alignment of a type in bytes for a target.
   --  See the method llvm::DataLayout::getTypeABISize.
   function ABIAlignmentOfType (TD : TargetDataRef; Ty: TypeRef)
                               return Unsigned_32;
   pragma Import (C, ABIAlignmentOfType, "LLVMABIAlignmentOfType");

   --  Computes the byte offset of the indexed struct element for a target.
   --  See the method llvm::StructLayout::getElementContainingOffset.
   function OffsetOfElement(TD : TargetDataRef;
                            StructTy : TypeRef;
                            Element : Unsigned_32)
                           return Unsigned_64;
   pragma Import (C, OffsetOfElement, "LLVMOffsetOfElement");

end LLVM.Target;