Implement aarch64 neon instruction set AdvSIMD (copy).
[oota-llvm.git] / utils / lldbDataFormatters.py
1 """
2 Load into LLDB with:
3 script import lldbDataFormatters
4 type synthetic add -x "^llvm::SmallVectorImpl<.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
5 type synthetic add -x "^llvm::SmallVector<.+,.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
6 """
7
8 # Pretty printer for llvm::SmallVector/llvm::SmallVectorImpl
9 class SmallVectorSynthProvider:
10     def __init__(self, valobj, dict):
11         self.valobj = valobj;
12         self.update() # initialize this provider
13
14     def num_children(self):
15         begin = self.begin.GetValueAsUnsigned(0)
16         end = self.end.GetValueAsUnsigned(0)
17         return (end - begin)/self.type_size
18
19     def get_child_index(self, name):
20         try:
21             return int(name.lstrip('[').rstrip(']'))
22         except:
23             return -1;
24
25     def get_child_at_index(self, index):
26         # Do bounds checking.
27         if index < 0:
28             return None
29         if index >= self.num_children():
30             return None;
31
32         offset = index * self.type_size
33         return self.begin.CreateChildAtOffset('['+str(index)+']',
34                                               offset, self.data_type)
35
36     def update(self):
37         self.begin = self.valobj.GetChildMemberWithName('BeginX')
38         self.end = self.valobj.GetChildMemberWithName('EndX')
39         the_type = self.valobj.GetType()
40         # If this is a reference type we have to dereference it to get to the
41         # template parameter.
42         if the_type.IsReferenceType():
43             the_type = the_type.GetDereferencedType()
44
45         self.data_type = the_type.GetTemplateArgumentType(0)
46         self.type_size = self.data_type.GetByteSize()
47         assert self.type_size != 0