Automatic Code Generation for Dense Linear Algebra