I have spent some time examining the llvm code now, and it seems most of
the hash_maps are keyed with pointers, and a few with ints. There is
also one place where the keys are std::string. All these are
unproblematic with the Visual Studio std_ext::hash_map since it provides
hash_value functions for all these types (note, it hashes char * as
pointers, not as strings - but char * is not used as a key anywhere in
LLVM). This means that although the way of adding your own hashing
functions is different, the default implementation works for 99% of all
the cases and the ADT/HashExtras.h file is not necessary.
BUT there is one place where llvm defines it's own hashing function, in
include/llvm/Target/TargetSchedInfo.h
template <> struct hash<llvm::OpCodePair> {
size_t operator()(const llvm::OpCodePair& pair) const {
return hash<long>()(pair.val);
}
};
which for Visual Studio can be replaced with:
const size_t hash_value(const llvm::OpCodePair& pair) {
return hash_value((long)pair.val);
}
however, it seems the OpCodePair class is never used - and specifically
never used for hash keys. Should this code be deleted? Also, Paolo is
building LLVM with Visual C, but using a GNU compatible STL. I don't
know how to detect which of these libraries is used, so it's a bit
tricky to make sure the right version is compiled.
I would like some input on these issues before submitting a patch. This
is the last issue remaining before the core of LLVM compiles
unmodified with Visual C...
m.
> Also, Paolo is building LLVM with Visual C, but using a GNU compatible > STL. I don't know how to detect which of these libraries is used, so > it's a bit tricky to make sure the right version is compiled.I would be happy to switch from STLPort to the standard Visual Studio STL.... --- Paolo Invernizzi
On Mon, 25 Oct 2004, Morten Ofstad wrote:> I have spent some time examining the llvm code now, and it seems most of > the hash_maps are keyed with pointers, and a few with ints. There is > also one place where the keys are std::string. All these are > unproblematic with the Visual Studio std_ext::hash_map since it provides > hash_value functions for all these types (note, it hashes char * as > pointers, not as strings - but char * is not used as a key anywhere in > LLVM).Ok.> This means that although the way of adding your own hashing > functions is different, the default implementation works for 99% of all > the cases and the ADT/HashExtras.h file is not necessary.Cute. :)> BUT there is one place where llvm defines it's own hashing function, in > include/llvm/Target/TargetSchedInfo.h...> however, it seems the OpCodePair class is never used - and specifically > never used for hash keys. Should this code be deleted?Yes, it appears to be dead. I nuked it here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041025/019816.html> I would like some input on these issues before submitting a patch. This > is the last issue remaining before the core of LLVM compiles > unmodified with Visual C...Very very nice! -Chris -- http://llvm.org/ http://nondot.org/sabre/