[ Content | Sidebar ]

Sea Plane

August 31st, 2017

I went with my mum to the Eastbourne air show, as we do every year. But this time they had something different, a sea plane!

Alas it decided not to actually land on the sea. Health ‘n’ safety no doubt.


August 30th, 2017

The doof.me.uk content engine seems to have ground of a halt as of late. Partly because I’ve been doing some boring things at the weekend, and partly because I had a running/gym induced leg injury and the physio wanted me to rest it a bit. Anyway, I did manage to get out last Saturday and do a walk from Tring to Dunstable.

Towards Ivinghoe Beacon

This seems to a pretty optimal route for the area: the scenery was excellent almost the whole way. Except for a slightly crummy bit skirting round the edge of Whipsnade Zoo. Although I did see a kangaroo.

Too Hot for Exploring

July 13th, 2017

Recently it’s got extremely hot in the southeast so I took an impromptu Monday off and went for two days exploring near Swindon and Avebury. Although really it’s just places I’ve explored before.

I’m not sure why, but I seemed to be the only person willing to go hiking in 30 degree heat and no shade. Hmm. Here on top of Pewsey Downs I didn’t see anyone for hours.

Harmondsworth Barn

June 17th, 2017

Here’s somewhere I’ve wanted to go ever since I moved to this part of northwest London but never had the chance, Harmondsworth Barn.

It’s a medieval great barn. One of the few places of that vintage in these parts, although it’s been upgraded and restored a lot over the years.

I originally heard about it as it was scheduled to be demolished to make way for the third runway at Heathrow, but it’s unclear to me whether it will survive under the latest plans.

The reason it took me so long to visit is that I can never get my head around “Nth Sunday of the month” type of opening days. And it’s only open in the summer months.


June 15th, 2017

Last Friday was entirely too sunny to spend in the office so I took an impromptu day off and went hiking in Chiltern Hills near home.

Originally I thought I’d get as far as Dunstable or Luton but that wasn’t going to happen so instead I stopped at Tring.

The one interesting bit happened right at the end where I spied a strange tower on a hitherto unexplored hill in the distance. After a bit of scrambling around I managed to climb up to it and it was this monument thing. Only open at the weekend apparently, which was a bit of a bummer.

Finally I managed to take this photo of off-scale-Englishness country scene.

Another Failed Circumnavigation

May 30th, 2017

A few weekends ago I tried a second time to do a full circumnavigation of High Wycombe, having not quite achieved it back in 2015. Success would be going in a big circle without cutting through any built-up area.

But the weather was a bit miserable and I discovered the bit I cut out last time was interminably dull. So I gave up after 18 miles. One day…

Oriental Pearl Tower

May 28th, 2017

Just one more China post! The evening before I flew home I finally managed to take a half-decent photo of the Oriental Pearl Tower in Shanghai. It’s much more interesting to visit the Pudong area at night instead of in the day. A lot of buildings have cool light shows, but not as impressive or coordinated as in Hong Kong.


May 24th, 2017

Anchang 安昌 is a delightful little water town just north of Shaoxing. I went there on a sunny Saturday and it was quite busy, but not crammed. You can get there easily from Shaoxing by taking the regular public bus number 118. It takes around one hour.

The town is very similar to Tongli which I visited around the same time last year. Instead of roads they have canals everywhere and these traditional low whitewashed buildings. Like so many of these “scenic spots” in China you buy a single ticket which lets you get into a variety of attractions like old houses, a 1920s bank, a temple, and so on. And then you spend the whole day strolling around peering at stuff and taking photos. It’s basically my ideal day out, as you might have gathered from this blog recently.

For lunch I had this appetising plate of 田螺 which I think is “river snail” in English. The lady in the restaurant was very keen for me to try it. And then she took a photo of me, which was a bit odd. The toothpick it seems is the standard method to extract them out from their shells. Hm. Anyway I washed it down with some 黄酒 which is the famous “Shaoxing rice wine” that comes from these parts, and also available in your local Tesco.


May 16th, 2017

And now as Michael Bolton might say, back to the good part. You might, wrongly, think this was part of my previous Chinese adventuring but actually I came back to the UK for a month and then work asked me to go back to Suzhou again for another week. So I dutifully did and after that was over went to Shaoxing in Zhejiang for a long weekend. One of the great things about business trips to China is you’re never short of new places to go on excursions. Unlike say, *cough* Norway *cough*.

Shaoxing canals

Shaoxing reminds me a lot of the older parts of Suzhou. It’s got the same white washed architecture and canals everywhere instead of roads. But it’s quieter, in a good way, and a lot less commercialised.

I didn’t actually spend that much time in the city itself, because I took all of Saturday to go out for a day trip. But I visited the most important site, or at least the one everyone told me to go to, Lu Xun’s birthplace. I hadn’t heard of him either, but he’s a famous early 20th century writer.

Suspicious character posing with Lu Xun

Around his birthplace area there are several well-preserved Qing dynasty houses which you can visit. For free as well! Which is quite unusual in China. And a few hundred meters away is a large classical garden, but not as impressive as the ones in Suzhou.

As an aside, the Chinese name 绍兴 ShaoXing seems to be almost impossible for me to pronounce. Every time I told someone 我周末去绍兴 they would just look at me blankly and be like “where..?”. My teacher is always complaining that I can’t pronounce other sh- words like 书 properly. And that followed by the elusive x-that-sounds-like-an-s is not a good combination. Also the 兴 is first tone like in 兴奋 not fourth tone like in 高兴. Once I figured this out my success rate increased to maybe 20%…

Using ORC with LLVM’s C API

May 11th, 2017

I recently updated the JIT back-end of my VHDL simulator to use LLVM’s new ORC API which was added in version 3.9. It has a couple of advantages, the two important ones for me were re-introduction of lazy-JIT-ing of functions, and that it works on Windows. Both features that were lost moving from the legacy JIT API to the newer MCJIT one. ORC is actually built as a layer on top of MCJIT though.

Documentation seems to be pretty scarce. There’s some example code but it all uses the C++ API so I thought it might be useful to write some notes on how I use it with the C API. You simply need to include this header and then either link against the LLVM shared library or llvm-config --libs orcjit.

#include <llvm-c/OrcBindings.h>

Initialise the LLVM libraries and MCJIT back-end which ORC is built on:


Let’s assume you already have an LLVM bitcode module from somewhere else:

LLVMModuleRef module = ...;

Unlike the MCJIT API and the original LLVM JIT API you need a “target machine” reference to create the ORC object. This is probably the only non-obvious part but a bit of searching in the other headers finds some functions to do it:

char *def_triple = LLVMGetDefaultTargetTriple();   // E.g. "x86_64-linux-gnu"
char *error;
LLVMTargetRef target_ref;
if (LLVMGetTargetFromTriple(def_triple, &target_ref, &error)) {
   // Fatal error
if (!LLVMTargetHasJIT(target_ref)) {
   // Fatal error, cannot do JIT on this platform
LLVMTargetMachineRef tm_ref =
   LLVMCreateTargetMachine(target_ref, def_triple, "", "",

The two empty string arguments to LLVMCreateTargetMachine are CPU and Features. I can’t work out what these are used for and everything works fine if you pass an empty string. On LLVM 4.0 you can pass NULL here but this crashes on 3.9.

I haven’t experimented with anything other the default relocation model, which seems to work everywhere I tried it, or the optimisation level.

Now we can actually create the ORC object:

LLVMOrcJITStackRef orc_ref = LLVMOrcCreateInstance(tm_ref);
LLVMOrcAddLazilyCompiledIR(orc_ref, module, orc_sym_resolver, NULL);

The only interesting argument is orc_sym_resolver. This is a pointer to callback ORC will use when it needs you to resolve a symbol.

static uint64_t orc_sym_resolver(const char *name, void *ctx)
   return (uint64_t)(uintptr_t)LLVMOrcGetSymbolAddress(orc_ref, name);

The function LLVMOrcGetSymbolAddress seems to do exactly what we want, but you could do some custom symbol lookup if required.

You can also use this function to trigger the lazy compilation and get a function pointer to the result. For example:

int (*main_fn)(void) = LLVMOrcGetSymbolAddress(orc_ref, "main");
int result = (*main_fn)();